VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get NT User Info (FullName, Groups) using ADSI

by Shannon Norrell (1 Submission)
Category: Windows System Services
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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.

Assumes
Uses ADSI (Active Directory Services) 2.0 or later.
Code Returns
Example from IMMEDIATE WINDOW: ================================================== NT UserName Webdood FullName Shannon Norrell This user belongs to the following NT Groups: Domain Users
API Declarations
Must Reference the ActiveDS Type Library. (activeds.tlb)

Rate Get NT User Info (FullName, Groups) using ADSI

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

Download this snippet    Add to My Saved Code

Get NT User Info (FullName, Groups) using ADSI Comments

No comments have been posted about Get NT User Info (FullName, Groups) using ADSI. Why not be the first to post a comment about Get NT User Info (FullName, Groups) using ADSI.

Post your comment

Subject:
Message:
0/1000 characters