Share via


User.IsUserMemberOf Method

Gets whether the current user is a member of the specified group.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Syntax

'Declaration
'Usage

Parameters

  • groupName
    The group name in the format of domain\groupname.

Return Value

true if the current user is a member of the specified group; otherwise false.

Exceptions

Exception type Condition

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

The parameter passed to this method isnot valid. For example, it is of the wrong type or format.

Remarks

Even though the IsUserMemberOf method is marked as security level 2, it is not always accessible. When a call is made to the IsUserMemberOf method, InfoPath first performs a security check to determine if access to this method is allowed. The security check confirms whether the calling code is trusted or not and it determines the location of the calling code.

If the calling code is trusted (as it is when, for example, the IsUserMemberOf method is called from an installed or signed InfoPath form template, or from trusted external code, such as an executable file on the local computer), InfoPath will allow full access to the IsUserMemberOf method.

If the calling code is not trusted, for example, if the call is coming from a domain-based InfoPath form template, InfoPath first checks where the call is being made from. If the call is from code that is not trusted in an InfoPath form template at a URL such as "https://www.contoso.com/example.xsn", then the call is from the Internet zone. InfoPath will deny access to the IsUserMemberOf method for all calls that are not trusted coming from the Internet zone. If the call is from a URL such as "http://contoso/example.xsn", then the call is from the Intranet zone. For a call that is not trusted from the Intranet zone, InfoPath checks whether the Internet Explorer user authentication settings allow automatic logon (in the Intranet zone only or for every logon). If Internet Explorer is configured for automatic logon, then InfoPath checks the user's group membership. If the group membership is public, InfoPath allows full access to the IsUserMemberOf method. If the group membership is not fully public, InfoPath hides the result. That is, InfoPath treats the group membership as if it were not visible. The return value in this case is always false because the group membership is not public. InfoPath does not report that access is denied.

Note

Group membership information is fully public if access to it is allowed and the information is visible by all non-anonymous users. If even a single non-anonymous user has been specifically denied access to membership information, then the group membership information is not fully public.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed only from code running in forms opened in Microsoft Office InfoPath 2007.

Example

In the following example, clicking the Button control displays whether the current user is a member of the specified group.

public void CTRL1_Clicked(object sender, ClickedEventArgs e)
{
   MessageBox.Show(
      this.Application.User.IsUserMemberOf(
      "CONTOSO\\Users").ToString());
}
Public Sub CTRL1_Clicked(ByVal sender As Object, _
   ByVal e As ClickedEventArgs)
   MessageBox.Show( _
      Me.Application.User.IsUserMemberOf("CONTOSO\\Users").ToString())
End Sub

See Also

Reference

User Class
User Members
Microsoft.Office.InfoPath Namespace