Please take a look at the code below. It successfully returns the DN for my computer and sets the description.
Please post your code so that we can take a look at why you are having problems. Based on what you stated. I would expect that either your database contains incorrect names or names that no longer exist in your domain. Have you checked the error codes when you do not get the results that you expected?
code:
$DN = TranslateName (3, "", 3, "@Domain\@wksta$$", 1)
? "DN = " + $DN[0]
? "Error = " + $DN[1]
? "ErrorText = " + $DN[2]
$obj = GetObject("LDAP://@domain/" + $DN[0])
? "GetObject: @error @Serror"
; Enumerate ALL properties
; Uncomment to show all properties
;EnumObjProps($obj)
? "Computer Description:" + $obj.description
$obj.description = "DSS Laptop"
$obj.SetInfo
Function EnumObjProps($object)
Dim $Class, $Schema, $Value, $property, $cont
$Class = GetObject($object.schema)
? "Class: " + $Class.Name
? "GUID: " + $Class.GUID
? "Implemented by: " + $Class.CLSID
If $Class.Container
? ? "Container Object"
? "Class Contains:"
For Each $cont In $Class.Containment
? " " + $cont
Next
Else
? ? "Leaf Object"
EndIf
? "Mandatory Properties in this Class: "
For Each $property In $Class.MandatoryProperties
? " " + $property
Next
? ? "Optional Properties in this Class: "
For Each $property In $Class.OptionalProperties
? " " + $property
Next
EndFunction
Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText
$Error = 0
$ErrorText = ""
$ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate")
$Error = @error
$ErrorText = @serror
if $Error = 0
$NameTranslate.Init ($InitType, $BindName)
$Error = @error
$ErrorText = @serror
if $Error = 0
$NameTranslate.Set ($LookupNameType, $LookupName)
$Error = @error
$ErrorText = @serror
if $Error = 0
$ReturnName = $NameTranslate.Get($ReturnNameType)
$Error = @error
$ErrorText = @serror
endif
endif
endif
$TranslateName = $ReturnName, $Error, $ErrorText
Endfunction