Get Current Domain Name

Posted by Naimishforu under VB.NET category on | Points: 40 | Views : 6260
Code :

   Public Function GetDomainName() As String

Dim strDomain As String

'Returns domain name and username
strDomain = System.Security.Principal.WindowsIdentity.GetCurrent.Name

'Extract domain name from full login
strDomain = Mid(strDomain, 1, InStr(strDomain, "\") - 1)

Return strDomain

End Function

Comments or Responses

Login to post response