User.LoginName Property

Gets the user's full credentials.

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

Syntax

'Declaration
Public MustOverride ReadOnly Property LoginName As String
    Get
'Usage
Dim instance As User
Dim value As String

value = instance.LoginName
public abstract string LoginName { get; }

Property Value

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

Exceptions

Exception Condition
SecurityException

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

Remarks

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.

Examples

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);
}
Public Sub CTRL1_Clicked(ByVal sender As Object, _
   ByVal e As ClickedEventArgs)
   MessageBox.Show(Me.Application.User.LoginName)
End Sub

See Also

Reference

User Class

User Members

Microsoft.Office.InfoPath Namespace