|
'Function: TransLDAP 'Arguments: 'Description: '----------------------------------------------------------------------------- Function TransLDAP(Domain,Obj)
DIM message DIM adsNameTranslate DIM ObjDN
CONST LOCATION = "TRANSLDAP"
ON ERROR RESUME NEXT
' writelog LOCATION, "Start " & LOCATION
' writelog LOCATION,"Translate: " obj & "@" domain
' Use NameTranslate to look up the computer in the directory Set adsNameTranslate = CreateObject("NameTranslate") adsNameTranslate.Init ADS_NAME_INITTYPE_GC, vbNullString
' Set the user name into nametranslate ' Specify unknown format, so that system will guess ' adsNameTranslate.Set ADS_NAME_TYPE_UNKNOWN, Domain & "\" & Obj adsNameTranslate.Set ADS_NAME_TYPE_UNKNOWN, obj & "@" & Domain
' Get the DN of the object ObjDN = adsNameTranslate.Get(ADS_NAME_TYPE_1779)
If ObjDN = "" then ' sendlog = true message = "****************** ObjDN is Null for: " & obj & "@" & domain TransLDAP = "" writelog LOCATION, message Else message = "ObjDN: " & ObjDN TransLDAP = "LDAP://" & ObjDN End if
set adsNameTranslate = nothing
' Writelog LOCATION, "End " & LOCATION
End Function
_____________--
SO then later he can call the function like this strAdsComputer = TransLDAP(strCompDomain,wshComputerName & "$") and TransLDAP(Group_Domain,group) strAdsMember = TransLDAP(AdsMemberDomain,AdsMember.Name)
Thanks in advance.
|