Hello everyone
I am having a strange thing happen and I wonder if anyone can help me see where I am going wrong. I wrote a vbscript/hta to search AD and display the results in a text box. The whole program works good until I was asked to add the field containing our mail stop. It took me awhile to figure out the name of the field but, I finally did the field name is "destinationIndicator". When I try to get that value however it always comes back empty. If I try to display the value in a msgBox the scripts errors saying there is a Null value, and if I use the function VarType that says its a Null value. If I use the command line, command csvde -f export.cvs -r "(&(objectClass=user)(sn=Thomas))" it generates a file with all my information and in the field named "destinationIndicator" is my mail stop, could someone tell me what I am missing. Below is a portion of my code that is getting the information from AD.
*****************************************************
' Determine DNS domain name.
Set oRootDSE = GetObject("GC://RootDSE")
sDNSDomain = oRootDSE.Get("defaultNamingContext")
sDNSDomain = Right(sDNSDomain, 20)
strLName = "(SN=" & strMySearch & ")"
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<GC://" & sDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)" & strLName & ")"
strAttributes = "cn,mail,telephoneNumber,company,streetAddress,l,co,SAMAccountName,postalcode,destinationIndicator"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Sort On") = "SN"
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
MsgBox "No user found by this name: " & strMySearch
End If
*****************************************************
This code is working it just doesn't seem to find the value stored in the "destinationIndicator". If you want more or the rest of the script let me know and thanks for any help I can get I have run out of ideas.
Thanks Randy
I am having a strange thing happen and I wonder if anyone can help me see where I am going wrong. I wrote a vbscript/hta to search AD and display the results in a text box. The whole program works good until I was asked to add the field containing our mail stop. It took me awhile to figure out the name of the field but, I finally did the field name is "destinationIndicator". When I try to get that value however it always comes back empty. If I try to display the value in a msgBox the scripts errors saying there is a Null value, and if I use the function VarType that says its a Null value. If I use the command line, command csvde -f export.cvs -r "(&(objectClass=user)(sn=Thomas))" it generates a file with all my information and in the field named "destinationIndicator" is my mail stop, could someone tell me what I am missing. Below is a portion of my code that is getting the information from AD.
*****************************************************
' Determine DNS domain name.
Set oRootDSE = GetObject("GC://RootDSE")
sDNSDomain = oRootDSE.Get("defaultNamingContext")
sDNSDomain = Right(sDNSDomain, 20)
strLName = "(SN=" & strMySearch & ")"
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<GC://" & sDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user)" & strLName & ")"
strAttributes = "cn,mail,telephoneNumber,company,streetAddress,l,co,SAMAccountName,postalcode,destinationIndicator"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Sort On") = "SN"
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
MsgBox "No user found by this name: " & strMySearch
End If
*****************************************************
This code is working it just doesn't seem to find the value stored in the "destinationIndicator". If you want more or the rest of the script let me know and thanks for any help I can get I have run out of ideas.
Thanks Randy