User.IsCurrentUser method

Returns true if the current user matches the specified user name.

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

Syntax

'Declaration
Function IsCurrentUser ( _
    bstrUsername As String _
) As Boolean
'Usage
Dim instance As User
Dim bstrUsername As String
Dim returnValue As Boolean

returnValue = instance.IsCurrentUser(bstrUsername)
bool IsCurrentUser(
    string bstrUsername
)

Parameters

  • bstrUsername
    Type: System.String

    The user name in the format of "domain\username."

Return value

Type: System.Boolean
true if the current user matches the specified name; otherwise false.

Remarks

Even though the IsCurrentUser method is marked as security level 0, it is not always accessible. When a call is made to the IsCurrentUser 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 IsCurrentUser 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 IsCurrentUser method.

If the calling code is not trusted (as in the circumstance of a call coming from a domain-based InfoPath form template or from script executing in Microsoft Internet Explorer), 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 denies access to the IsCurrentUser 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 allows full access to the IsCurrentUser method. Otherwise, access to the IsCurrentUser method is denied.

Important

This member can be accessed without restrictions.

Examples

In the following example, the IsCurrentUser method of the User object is used to determine if the current user equals "UserDomain\NancyDavilio".

bool userMatched;
userMatched = thisApplication.User.IsCurrentUser(@"UserDomain\NancyDavolio");

See also

Reference

User interface

User members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace