This document is archived and information here might be outdated.  Recommended version.


Get DomainNameUserName Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Get DomainNameUserName Snippet

Obtain the DomainName and UserName of the currently logged in user.

[C#]
///<summary>Obtain the DomainName and UserName of the currently logged in user.</summary>
/// 
///<returns>A System.String that is the user's DomainName\UserName.</returns>
/// 
///<remarks></remarks>
public System.String GetDomainNameUserName()
{

  System.Security.Principal.WindowsIdentity windowsIdentity=System.Security.Principal.WindowsIdentity.GetCurrent();
  System.String windowsLoginName=windowsIdentity.Name;

  return windowsLoginName;

}
[Visual Basic .NET]
'''<summary>Obtain the DomainName and UserName of the currently logged in user.</summary>
''' 
'''<returns>A System.String that is the user's DomainName\UserName.</returns>
''' 
'''<remarks></remarks>
Public Function GetDomainNameUserName() As System.String

  Dim windowsIdentity As System.Security.Principal.WindowsIdentity=System.Security.Principal.WindowsIdentity.GetCurrent
  Dim windowsLoginName As System.String=windowsIdentity.Name

  Return windowsLoginName

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • System