All pastes #470018 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-04 00:47 UTC
rendered paste body
On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

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.Properties("Searchscope") = ADS_SCOPE_SUBTREE 

objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://ou=Temp,dc=primaryt,dc=co,dc=uk' WHERE objectCategory='user'"  

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strUserPath = objRecordSet.Fields("AdsPath").Value
    Set objUser = GetObject(strUserPath)
    strOffice = objUser.physicalDeliveryOfficeName
    objUser.Description = strOffice
    objUser.SetInfo
    objRecordSet.MoveNext

Dim StrPrefix
Dim StrContainer
Dim StrSuffix
Dim StrFQDN
'StrPrefix = "(""LDAP://cn="
StrPrefix = "LDAP://cn="
StrContainer = StrOffice
StrSuffix = ",ou=Temp,dc=primaryt,dc=co,dc=uk"
'StrSuffix = ",ou=Temp,dc=primaryt,dc=co,dc=uk"")"
StrFQDN = StrPrefix & StrContainer & StrSuffix
WScript.Echo "Group is now = " & StrFQDN 


objGroup = StrFQDN
'    ("LDAP://cn=test1,ou=Temp,dc=primaryt,dc=co,dc=uk")
objGroup.Add(objUser.ADsPath)


'Set objGroup = GetObject _
'    & StrFQDN
'    objGroup.Add(objRecordSet.Fields("ADsPath").Value)
'WScript.Echo " & objGroup
Loop