I found a script that looks through A/D and lists all the users. I modified it a touch to look through and find all the contacts - we have about 500. This works great, but I'd like to add a little more information on the contacts and don't quite know how or what to add.
Right now all I get is the contact name, I'd also like the email address and the OU tree that it's located in.
Thanks!
h
Right now all I get is the contact name, I'd also like the email address and the OU tree that it's located in.
Thanks!
h
Code:
strDomain = "dc=domainname,dc=local"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutput = objFSO.CreateTextFile("contacts.csv", True)
strLDAP = "<LDAP://" & strDomain & ">;"
strFilter = "(&(objectclass=contact)(objectcategory=person));"
strAttrs = "name;"
strScope = "subtree"
Set cnContacts = CreateObject("ADODB.Connection")
cnContacts.Provider = "ADsDSOObject"
cnContacts.Open "Active Directory Provider"
set rsContacts = cnContacts.Execute(strLDAP & strFilter & strAttrs & strScope)
rsContacts.MoveFirst
while Not rsContacts.EOF
userlist = userlist & rsContacts.Fields(0).Value & vbCrLf
rsContacts.MoveNext
Wend
objOutput.WriteLine userlist
objOutput.Close
MsgBox "done"