Share via


User2.LoginName property

Gets the user's full credentials.

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

Syntax

'Declaration
ReadOnly Property LoginName As String
    Get
'Usage
Dim instance As User2
Dim value As String

value = instance.LoginName
string LoginName { get; }

Property value

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

Remarks

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.

Because the LoginName property is newin Microsoft InfoPath, you must declare and cast to the User2 type to access it. For more information, see How to: Use Microsoft.Office.Interop.InfoPath.SemiTrust Members That Are Not Compatible with InfoPath 2003.

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.

Examples

In the following example, the LoginName property is used to display the current user's login credentials.

User2 thisUser = (User2)thisApplication.User;
thisXDocument.UI.Alert(thisUser.LoginName);
Dim thisUser As User2  = DirectCast(thisApplication.User, User2)
thisXDocument.UI.Alert(thisUser.LoginName)

See also

Reference

User2 interface

User2 members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace