Guys,
I am looking to connect to AD and pull some of the following information from it.
I am looking to get First Name, Last Name, Phone Number etc.
One of the criteria is to look at the "Member of" and determine if he/she is a member of the F-Accounting or F-MHR.
Then output the result into a csv file in the following format below.
"Bob","Dole", "991-888-3211","MHR", " "
The "Accounting" or "MHR" will be static derived from the F-Accounting or F-MHR in the member of group. Also if there is any blank field in the Phone Number field or any field, it will still have quotation " " in between.
Thanks a lot.
tnt
I have looked at this sample script from MS and wonder why they didn't need a password/username to connect to AD
----------------------------------------------
On Error Resume Next
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.CommandText = _
"<LDAP://dc=fabrikam,dc=com>;(&(objectCategory=User)" & _
"(!(telephoneNumber=*)));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop
I am looking to connect to AD and pull some of the following information from it.
I am looking to get First Name, Last Name, Phone Number etc.
One of the criteria is to look at the "Member of" and determine if he/she is a member of the F-Accounting or F-MHR.
Then output the result into a csv file in the following format below.
"Bob","Dole", "991-888-3211","MHR", " "
The "Accounting" or "MHR" will be static derived from the F-Accounting or F-MHR in the member of group. Also if there is any blank field in the Phone Number field or any field, it will still have quotation " " in between.
Thanks a lot.
tnt
I have looked at this sample script from MS and wonder why they didn't need a password/username to connect to AD
----------------------------------------------
On Error Resume Next
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.CommandText = _
"<LDAP://dc=fabrikam,dc=com>;(&(objectCategory=User)" & _
"(!(telephoneNumber=*)));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name").Value
objRecordSet.MoveNext
Loop