User2.UserName Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets only the user's username.
public:
property System::String ^ UserName { System::String ^ get(); };
public string UserName { get; }
member this.UserName : string
Public ReadOnly Property UserName As String
Property Value
The user's username.
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)
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, you must declare and cast to the User2 type to access it. For more information, see How to: Use Object Model 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.