Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory Query 1

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
Does anyone have code or a model of a procedure that will allow me to query members of the Active Directory?

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Add a reference to Active DS Type Library (activeds.tlb) to your VBA project, this will allow you to query Active Directory. Here is a small routine that will allow you to return a users Full Name as listed in AD.
Code:
[navy]Public Function[/navy] ADsFullName() [navy]As String[/navy]
[navy]Dim[/navy] objIADsUser [navy]As[/navy] ActiveDs.IADsUser
[navy]Dim[/navy] strUserID [navy]As String[/navy], strComputerName [navy]As String[/navy]
strComputerName = Environ$("COMPUTERNAME")
strUserID = Environ$("USERNAME")
Set objIADsUser = GetObject("WinNT://" & _
  strComputerName & "/" & strUserID & ",user")
ADsFullName = objIADsUser.FullName
Set objIADsUser = [navy]Nothing[/navy]
[navy]End Function[/navy]

Hope this helps,
CMP

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top