Export (0) Print
Expand All

User.LoginName property

Gets the user's full credentials.

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

public abstract string LoginName { get; }

Property value

Type: System.String
The user's credentials as domain\username.

ExceptionCondition
SecurityException

The form template is not configured for Full Trust using the Security and Trust category of the Form Options dialog box.

When the form is opened in InfoPath, the LoginName property returns a user's credentials as domain\username. If the user's account does not belong to a domain, the property returns only username.

This is equivalent to calling System.Environment.UserDomainName+"\\"+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, the LoginName property returns the SharePoint credentials of the user that is editing the form. This is equivalent to calling the SharePoint SPUser.LoginName property.

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

In the following example, clicking the Button control displays the current user's login credentials.

public void CTRL1_Clicked(object sender, ClickedEventArgs e)
{
   MessageBox.Show(this.Application.User.LoginName);
}
Show:
© 2014 Microsoft