Advertisement
Java_Volume1 Windows System Services #92253

Get NT User Info (FullName, Groups) using ADSI

Example code showing how one may extract NT Domain User information using ADSI (Active Directory Service Interfaces). This code simply extracts a user's FullName and lists the Groups to which he/she belongs, given his username. This code will work across domains, provided the correct authentication values (username, password) are inserted.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private oIADS As ActiveDs.IADsContainer
Private oUser As ActiveDs.IADsUser
Private oGroup As ActiveDs.IADsGroup
Private Sub Form_Load()
  txtDomain = "MYDOMAIN"
  usrName = "Administrator"
  usrPassword = "sa"
  usrNameOfInterest = "WebDood"
  
  Set oIADS = GetObject("WinNT:").OpenDSObject("WinNT://" & txtDomain, usrName, usrPassword, 1)
  Set oUser = oIADS.GetObject("user", usrNameOfInterest)
  With oUser
   Debug.Print "NT UserName" & Space$(8) & .Name
   Debug.Print "FullName" & Space$(11) & .FullName
   Debug.Print "This user belongs to the following NT Groups:"
   For Each oGroup In .Groups
     Debug.Print vbTab & oGroup.Name
   Next
  End With
  
End Sub
Original Comments (3)
Recovered from Wayback Machine