User.LoginName Property

Gets the user's full credentials.

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

Property Value

The user's credentials as domain\username.

Exception typeCondition


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 Microsoft Office Forms Server 2007 or from an appropriately configured document library in Microsoft Office SharePoint Server 2007 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 as 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 Office InfoPath 2007 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)

Community Additions