This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Get DomainNameUserName Snippet (ArcObjects .NET 10.4 SDK) |
Obtain the DomainName and UserName of the currently logged in user.
///<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; }
'''<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