Page 1 of 2 12>
Topic Options
#140778 - 2005-06-01 08:17 PM Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
On a few users, the TranslateName function does not work - as in it does not return anything. I am trying to query AD to see what OU the computer that is being logged on to resides in and it returns nothing. For some reason, I think this is a user problem. I copied the user account for one of the users that was having the issue and I get the same problem under the new account. If I log in to the machine, I have no problems.

As part of my troubleshooting, I added the user as a member of the Local Admins group on the box - that did not help.

So I am just wondering if anyone has had this problem before. I added a loop in a test script to keep querying if nothing was returned to rule out an intermittent problem with the server/AD, and that just results in an endless loop of 0 returns...

Any help would be appreciated.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140779 - 2005-06-01 11:58 PM Re: Problem with TranslateName
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, normal user can't query information about a networked computer if he is not locked on it?
_________________________
!

download KiXnet

Top
#140780 - 2005-06-02 01:01 AM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

so, normal user can't query information about a networked computer if he is not locked on it?




No - The problem is that I run TranslateName at the beginning of the login script to determine what OU the User and Computer are in and then spawn other scripts based on this information. For a couple of users, nothing is returned by TranslateName, while 99% of the others it works and I can't figure out why. I tried several things to troubleshoot, but I just don't get it.

Thanks for looking!
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140781 - 2005-06-02 06:08 AM Re: Problem with TranslateName
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
TranslateName relies on the SamAccountName property on the AD account. First use LDP.exe to review the object you want to lookup. Make sure that the SamAccountName matches what you are using as the name to query. Make sure that any new objects like new user and computer accounts have time to replicate fully.

Have you examined the error codes returned by TranslateName? Did the INIT fail or the SET fail? If these two succeed then the GET should have no problem.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#140782 - 2005-06-02 01:33 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
These are not new users, and the SamAccountName matches perfectly.

The problem I am having is that NOTHING is returned. No $ReturnName, no $Error, and no $ErrorText, so in my code:

Code:

$DN = TranslateName (3, "", 3, "@Domain\@wksta$", 1)
$DN = $DN[0]
$DN = split($DN,',DC=')[0]
$DN = Split($DN,',OU=')
$ubound = ubound($DN)
If $ubound > 1
$ComputerLOC = $DN[$ubound]
$secondLevel = $DN[$ubound-1]
If $ComputerLOC = 'HQ'
if instr('BIR;HAT;HFR',$secondLevel)
$ComputerLOC = $secondLevel
EndIf
EndIf
EndIf
If $DN[1] = "Metaframe"
$ComputerLOC = "CITRIX"
EndIf
If $DN[1] = "Memphis"
$ComputerLOC = "MER"
EndIf



$DN is not populated at all and I get an error at the line If $DN[1] yadda - "Array reference out of Bounds" or something like that...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140783 - 2005-06-02 01:36 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Ok this time I ran it and I got:
Code:

2147352567
COM exception error "Init" - ((null) - (null)) [-2147352567/80020009]

_________________________
-- oobnuker - .KIX hack - no really.

Top
#140784 - 2005-06-02 01:49 PM Re: Problem with TranslateName
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so there was error after all.
_________________________
!

download KiXnet

Top
#140785 - 2005-06-02 05:09 PM Re: Problem with TranslateName
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Based on you use of the inputs in TranslateName (3, "", 3, "@Domain\@wksta$", 1), you client can not find the global catalog. This may be a DNS issue.

Try binding to the domain as another test.

TranslateName (1, @Domain, 3, "@Domain\@wksta$", 1)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#140786 - 2005-06-02 05:44 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Based on you use of the inputs in TranslateName (3, "", 3, "@Domain\@wksta$", 1), you client can not find the global catalog. This may be a DNS issue.

Try binding to the domain as another test.

TranslateName (1, @Domain, 3, "@Domain\@wksta$", 1)




I tried the following:
Code:

;$DN = TranslateName (1, @DOMAIN, 3, "@Domain\@wksta$", 1)
;$DN = TranslateName (3, "", 3, "@Domain\@wksta$", 1)
$DN = TranslateName (2, "HQDC1", 3, "@Domain\@wksta$", 1)


And I get the same error each time.

Edit: And furthermore - I don't understand how a DNS issue can be user specific. Not that I am doubting you, I'm just stumped on this one...


Edited by oobnuker (2005-06-02 05:46 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140787 - 2005-06-02 05:53 PM Re: Problem with TranslateName
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
So you are saying that from the same computer one user gets data returned and a different user does not?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#140788 - 2005-06-02 05:57 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

So you are saying that from the same computer one user gets data returned and a different user does not?




Indeed. I added the user account in question to the local Admins group for the box thinking that it was something like that and it did not help.

Also, I made a copy of the user that is having problems, and the copied account has problems too. It is all very strange. I tried looking at that ldp.exe program that you mentioned, but I am not really up to speed on my ldap.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140789 - 2005-06-02 06:25 PM Re: Problem with TranslateName
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I suspect it is permissions, but not local perms but rather AD perms.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140790 - 2005-06-02 06:29 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

I suspect it is permissions, but not local perms but rather AD perms.




Any ideas in which direction I should be looking to narrow that down? I am not aware of the "Allow DNS lookup" checkbox
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140791 - 2005-06-02 06:37 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Another idea is if someone would provide me with another way to return the same info - be it a piece of VBS or whatever, to see if it works that way...
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140792 - 2005-06-02 07:38 PM Re: Problem with TranslateName
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
AD allows for a lot of granularity with perms to various pieces of the tree. I am confident that it is not a "Allow DNS lookup" perm problem. It only looks to DNS for GC reference, not for the AD query. For the AD query, it looks to well.... AD.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140793 - 2005-06-02 08:10 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
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.


Edited by oobnuker (2005-06-02 08:12 PM)

Top
#140794 - 2005-06-02 08:58 PM Re: Problem with TranslateName
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Give fnLDAPQuery() a try. Here is an example for the current workstation...

Code:

; == Return the distinguishedName for the computer ===================
$aAttributes = "distinguishedName"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$strFilter = "(&(objectClass=Computer)(Name="+@WKSTA+"))"

$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter)
@ERROR " | " @SERROR ?

For Each $Result in $aResults
$Result ?
Next


Top
#140795 - 2005-06-02 09:00 PM Re: Problem with TranslateName
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Trying to determine if this is a permissions issue.

Place the user account that does not work into the domain Adminstorators group. From the computer that you have been doing the previous testing, does the script work with th the user being a domain admin?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#140796 - 2005-06-02 09:19 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Give fnLDAPQuery() a try. Here is an example for the current workstation...

Code:

; == Return the distinguishedName for the computer ===================
$aAttributes = "distinguishedName"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$strFilter = "(&(objectClass=Computer)(Name="+@WKSTA+"))"

$aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter)
@ERROR " | " @SERROR ?

For Each $Result in $aResults
$Result ?
Next






I'll take a look at this when I get a chance. Thanks.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#140797 - 2005-06-02 09:23 PM Re: Problem with TranslateName
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

Trying to determine if this is a permissions issue.

Place the user account that does not work into the domain Adminstorators group. From the computer that you have been doing the previous testing, does the script work with th the user being a domain admin?




I tried this this morning and it didn't work. I double checked that the replication had gone through and it had. Domain Admins was not the answer...

In the meantime, with that piece of .VBS I have managed to insert a work around by modifying the VBS script to also look for computer accounts. I needed to get something in place because the entire script revolves around the OU info for the user and system - it is my brainchild and we will eventually be implementing it for 2500 users.

Code:

;Determine Computer OU
? Color $SC1 "- Querying Active Directory..."
$DN = TranslateName (3, "", 3, "@Domain\@wksta$", 1)
$DN = $DN[0]
:LOOKUPFAILED
$DN = split($DN,',DC=')[0]
$DN = Split($DN,',OU=')
$ubound = ubound($DN)
If $ubound > 1
$ComputerLOC = $DN[$ubound]
$secondLevel = $DN[$ubound-1]
If $ComputerLOC = 'HQ'
if instr('BIR;HAT;HFR',$secondLevel)
$ComputerLOC = $secondLevel
EndIf
EndIf
EndIf
If UBound($DN) > 0
Select
Case $DN[1] = "Metaframe" $ComputerLOC = "CITRIX"
Case $DN[1] = "Memphis" $ComputerLOC = "MER"
EndSelect
Else
? Color $SC3 "- Please Wait..." Color $SC1
Shell "%COMSPEC% /C cscript.exe /NoLogo @LDrive\Global\computerdn.vbs @wksta$ > %TEMP%\cdn.txt"
Shell "%COMSPEC% /C cscript.exe /NoLogo @LDrive\Global\userdn.vbs @USERID > %TEMP%\udn.txt"
$FH = FreeFileHandle()
$ = Open($FH, "%TEMP%\cdn.txt")
$DN = ReadLine($FH)
$ = Close($FH)
$FH = FreeFileHandle()
$ = Open($FH, "%TEMP%\udn.txt")
$LOOKUPFAILED = "1"
$DN2 = ReadLine($FH)
$ = Close($FH)
Goto LOOKUPFAILED
EndIf

;Determine User OU
If $LOOKUPFAILED <> "1"
$DN2 = TranslateName (3, "", 3, "@LDomain\@USERID", 1)
$DN2 = $DN2[0]
EndIf
$DN2 = split($DN2,',DC=')[0]
$DN2 = Split($DN2,',OU=')
$ubound = ubound($DN2)
If $ubound > 1
$USERLOC = $DN2[$ubound]
$secondLevel = $DN2[$ubound-1]
If $USERLOC = 'HQ'
if instr('BIR;HAT;HFR',$secondLevel)
$USERLOC = $secondLevel
EndIf
EndIf
EndIf



It works, but there is now obviously a dely as it shells out to run the VBS.

I am really curious as to why this is happening, and I would rather not go with the VBS solution long term.

Thanks for all of your help with this!


Edited by oobnuker (2005-06-02 09:25 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.081 seconds in which 0.033 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org