Share via


User.LoginName Property (Microsoft.Office.InfoPath)

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
'Usage
Dim instance As User
Dim value As String

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

Property Value

The user's credentials as domain\username.

Exceptions

Exception type 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 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.

Example

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