Please use @error and @Serror to return the error of the GetObject. You should also try outputing each of your variables to see that they contain what you think they should.

$TextBox.Text is not a valid variable name. Are you using Kixforms?

This code works for me using Kix32. Please start with this for testing and let me know the result. Code:
break On
? @kix
$TextBox = 'domain1\user1'
? $TextBox
$ldap = TranslateName(1, @domain, 3, $TextBox, 1)
? $ldap
?
? "LDAP://tycoelectronics/" + $ldap
$UserProperties = GetObject("LDAP://domain1/"+$ldap)
? "@error @serror"
? $userProperties.SAMAccountName

Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $NameTranslate, $ReturnName

$ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate")
if @Error = 0
$NameTranslate.Init ($InitType, $BindName)
if @Error = 0
$NameTranslate.Set ($LookupNameType, $LookupName)
if @Error = 0
$ReturnName = $NameTranslate.Get($ReturnNameType)
if @Error <> 0
Writelog("TranslateName: Get error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: Set error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: Init error " + @error + " " + @serror)
Writelog("TranslateName: (" + $InitType + ", " + $BindName+ ", " + $LookupNameType + ", " + $LookupName + ", " + $ReturnNameType + ")")
endif
else
Writelog("TranslateName: CreateObject error " + @error + " " + @serror)
endif
$TranslateName = $ReturnName
Endfunction




_________________________
Home page: http://www.kixhelp.com/hb/