Travis, the following should query your GC and return a | (pipe) delimited text file with a few attributes including “mail.” Have a look to see if that’s what you want. This is adapted from scripts found elsewhere, created by folks smarter than me ;-) YMMV
Change the dc=myRootDomain to the appropriate root in your environment, and watch for line wraps in the code.
Dim strLogFile strLogFile = "c:\temp\user_location.txt"
Set fso = CreateObject("Scripting.FileSystemObject") Set objFile = fso.CreateTextFile(strLogFile, 8, True)
Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Sort On") = "sAMAccountName" objCommand.Properties("Time Limit") = 0 objCommand.Properties("Timeout") = 0
objCommand.CommandText = _ "<GC://dc=myRootDomain,dc=com>;" & _ "(&(objectCategory=person)(objectClass=user));" & _ "sAMAccountName,sn,givenName,mail;subtree"
Set objRecordSet = objCommand.Execute
While Not objRecordset.EOF objFile.Writeline objRecordset.Fields("sAMAccountName").Value & "|" & objRecordset.Fields("sn").Value & "|" & objRecordset.Fields("givenName").Value & "|" & objRecordset.Fields("mail").Value objRecordset.MoveNext Wend
objConnection.Close
MsgBox "Query has completed. You may view the file c:\temp\user_attribs.txt."
<mc>
|
Title: Message
- [ActiveDir] ldifde and/or csdve Travis.Weeks
- RE: [ActiveDir] ldifde and/or csdve Joe
- RE: [ActiveDir] ldifde and/or csdve Creamer, Mark
- RE: [ActiveDir] ldifde and/or csdve Chianese, David P.
- RE: [ActiveDir] ldifde and/or csdve Mulnick, Al
- RE: [ActiveDir] ldifde and/or csdve Roger Seielstad
- RE: [ActiveDir] ldifde and/or csdve Tony Murray
- RE: [ActiveDir] ldifde and/or csdve Roger Seielstad
- RE: [ActiveDir] ldifde and/or csdve Roger Seielstad
- RE: [ActiveDir] ldifde and/or csdve Roger Seielstad