Permission.Add method

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

Namespace:  Microsoft.Office.Interop.InfoPath
Assembly:  Microsoft.Office.Interop.InfoPath (in Microsoft.Office.Interop.InfoPath.dll)

Syntax

'Declaration
Function Add ( _
    bstrUserId As String, _
    varPermission As Object, _
    varExpirationDate As Object _
) As UserPermissionObject
'Usage
Dim instance As Permission
Dim bstrUserId As String
Dim varPermission As Object
Dim varExpirationDate As Object
Dim returnValue As UserPermissionObject

returnValue = instance.Add(bstrUserId, _
    varPermission, varExpirationDate)
UserPermissionObject Add(
    string bstrUserId,
    Object varPermission,
    Object varExpirationDate
)

Parameters

  • bstrUserId
    Type: System.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
    Type: System.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
    Type: System.Object

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

Return value

Type: Microsoft.Office.Interop.InfoPath.UserPermissionObject
A UserPermissionObject that represents the specified user.

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.

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)

See also

Reference

Permission interface

Permission members

Microsoft.Office.Interop.InfoPath namespace