Поделиться через


User2.UserName Property

Gets only the user's username.

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

Syntax

'Declaration
ReadOnly Property UserName As String
    Get
'Usage
Dim instance As User2
Dim value As String

value = instance.UserName
string UserName { get; }

Property Value

Type: System.String
The user's username.

Remarks

Calling the UserName property is equivalent to calling System.Environment.UserName.

Note

The Local Intranet zone permissions allow reading the username from the environment, so this method can be called by domain-based form templates.

Because the UserName property is newin Microsoft InfoPath 2010, you must declare and cast to the User2 type to access it. For more information, see How to: Use Microsoft.Office.Interop.InfoPath.SemiTrust Members That Are Not Compatible with InfoPath 2003.

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.

Examples

In the following example, the UserName property is used to display the current user's login credentials.

User2 thisUser = (User2)thisApplication.User;
thisXDocument.UI.Alert(thisUser.UserName);
Dim thisUser As User2  = DirectCast(thisApplication.User, User2)
thisXDocument.UI.Alert(thisUser.UserName)

See Also

Reference

User2 Interface

User2 Members

Microsoft.Office.Interop.InfoPath.SemiTrust Namespace