Edit

Share via


Permission.Add(String, Object, Object) Method

Definition

Creates a new set of permissions on the current form for the specified user with the specified permissions and an expiration date.

public Microsoft.Office.Interop.InfoPath.UserPermissionObject Add (string bstrUserId, object varPermission, object varExpirationDate);
abstract member Add : string * obj * obj -> Microsoft.Office.Interop.InfoPath.UserPermissionObject
Public Function Add (bstrUserId As String, Optional varPermission As Object, Optional varExpirationDate As Object) As UserPermissionObject

Parameters

bstrUserId
String

The e-mail address in the format user@domain.com of the user to whom permissions on the current form are being granted. Required.

varPermission
Object

The permissions on the current form that are being granted to the specified user as a combination of one or more MsoPermission values. Optional.

varExpirationDate
Object

The expiration date for the permissions that are being granted as a System.DateTime value. Optional.

Returns

A UserPermissionObject that represents the specified user.

Examples

In the following example, the Add method is used to add a new user to the form, assign that user to the Full Control access level, and set an expiration date of two days from the current date.

This example requires a using or Imports directive for the Microsoft.Office.Core namespace in the declarations section of the form module.

_XDocument3 thisDoc = (_XDocument3)thisXDocument;

string strExpirationDate = DateTime.Today.AddDays(2).ToString();
DateTime dtExpirationDate = DateTime.Parse(strExpirationDate);

thisDoc.Permission.Add("someone@example.com",
   msoPermission.msoPermissionFullControl, dtExpirationDate);
Dim thisDoc As _XDocument3 = DirectCast(thisXDocument, _XDocument3)

Dim strExpirationDate As String = _
   DateTime.Today.AddDays(2).ToString()
dtExpirationDate As DateTime = DateTime.Parse(strExpirationDate)

thisDoc.Permission.UserPermissions.Add("someone@example.com", _
   msoPermission.msoPermissionFullControl, dtExpirationDate)

Remarks

To access the MsoPermission enumeration values for setting the varPermission parameter, you must set a reference to the Microsoft Office 14.0 Object Library using COM tab of the Add Reference dialog box in Visual Studio 2012 or Visual Studio. This will establish a reference to the members of the Microsoft.Office.Core namespace.

Applies to