There is an "application programming interface" (API) for Active Directory.
It's called Active Directory Services Interface (ADSI), and there's quite a
lot of information about it on MSDN. Start at
http://msdn.microsoft.com/library/en-us/adsi/adsi/active_directory_service_interfaces_adsi.asp.
The following Office VBA macro displays the user's name and home directory.
Before pasting it into the VBA editor, go to Tools > References and put a
checkmark next to "Active DS Type Library".
Sub ADSI_demo()
Dim domainName As String, userName As String
Dim ADSuser As ActiveDs.IADsUser
domainName = InputBox("Domain:", "ADSI Demo")
If domainName = "" Then Exit Sub
userName = InputBox("User login:", "ADSI Demo")
If userName = "" Then Exit Sub
On Error GoTo noData
Set ADSuser = GetObject("WinNT://" & domainName & "/" & userName)
MsgBox ADSuser.FullName & vbCr & ADSuser.HomeDirectory
Set ADSuser = Nothing
Exit Sub
noData:
MsgBox Err.Number & vbCr & Err.Description
End Sub
You can experiment with the properties of the ADSuser variable -- for
example, delete ".HomeDirectory" and type the dot to get a popup list of all
the properties that are available, such as TelephoneNumber or
OfficeLocations. If your particular directory doesn't contain entries for
those properties, though, you'll get an error message when you try to
retrieve the data.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.