User.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:
abstract property System::String ^ UserName { System::String ^ get(); };
public abstract string UserName { get; }
member this.UserName : string
Public MustOverride ReadOnly Property UserName As String
Property Value
The user's username.
Examples
In the following example, clicking the Button control displays the current user's username only.
public void CTRL1_Clicked(object sender, ClickedEventArgs e)
{
MessageBox.Show(this.Application.User.UserName);
}
Public Sub CTRL1_Clicked(ByVal sender As Object, _
ByVal e As ClickedEventArgs)
MessageBox.Show(Me.Application.User.UserName)
End Sub
Remarks
When the form is opened in the InfoPath editor, calling the UserName property is equivalent to calling System.Environment.UserName.
When the form is deployed to and opened from an appropriately configured document library in Microsoft SharePoint Server 2010 running InfoPath Forms Services, calling the UserName property is equivalent to calling the SharePoint SPUser.NameSPUser.LoginNameLoginName property.
Note: The Local Intranet zone permissions allow reading the username from the environment, so this method can be called by domain-based form templates.
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 from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.