OK - I found some .VBS code that returns the DN and the query works logged in as the user that can not seem to get it via the TranslateName UDF. I will attach the code here for reference:
Code:
On Error Resume Next
Dim oUser,oArgs
Set oArgs=WScript.Arguments
strUser=oArgs(0)
UserDN=GetDN(strUser)
WScript.Echo UserDN
WScript.quit
Function GetDN(samAccount)
On Error Resume Next
GetDN=samAccount & " NotFound"
set RootDSE=GetObject("LDAP://RootDSE")
set myDomain=GetObject("LDAP://"&RootDSE.get("DefaultNamingContext"))
'the query should all be on one line
strQuery="Select sAMAccountname,cn,distinguishedname from
'broken line
'" & myDomain.ADSPath & "' Where objectcategory='person' AND objectclass='user'" & " AND sAMAccountName='" & samAccount & "'"
set cat=GetObject("GC:")
for each obj in cat
set GC=obj
Next
AdsPath=GC.ADSPath
Set conn=Createobject("ADODB.Connection")
Set cmd=CreateObject("ADODB.Command")
conn.Provider="ADSDSOObject"
conn.Open
set cmd.ActiveConnection=conn
Set RS=conn.Execute(strQuery)
Do while not RS.EOF
GetDN=rs.Fields("distinguishedname")
rs.movenext
Loop
rs.Close
conn.Close
Set conn=Nothing
set cmd=Nothing
set RootDSE=Nothing
set cat=Nothing
set RS=nothing
End Function
'EOF
Returns the full Distinguished Name of the user account that is having the problem doing the same thing with the UDF. I have been discussing the Computer's OU lookup, but I am also looking up the User's OU with this:
Code:
$DN2 = TranslateName (3, "", 3, "@LDomain\@USERID", 1)
Which returns nothing.