Does anyone have a code example that gathers information from AD?
e.g. If I provide a persons logon name is it possible to provide details
like phone number etc etc and show the data in a messagebox or into a
document?
Any help would be really great!!
Thanks for your time!
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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
What about if I didn't have a userid but a full name instead, is it possible
to gather the same information without using a UserID??
Thanks again
Try posting your question in the newsgroups
microsoft.public.active.directory.interfaces
(http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.active.directory.interfaces&cat=en_us_1265f606-89a9-4586-af70-a8d4b237b327&lang=en&cr=us)
and microsoft.public.windows.server.active_directory
(http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.windows.server.active_directory&cat=en_us_5bd43452-4bab-4720-8df9-d5f37d3153b9&lang=en&cr=us).
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.