Re: NameTranslate object error
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 21 Apr 2007 11:48:20 -0500
First, the snippet assumes you have already bound to the WshNetwork object.
I believe you have. Next, you are doing two translations. First you convert
the NT Name of the current user to the Display Name, then you convert the
Display Name to the Distinguished Name. You should instead convert directly
from the NT name to the Distinguished Name.
Also, this accounts for the error you experience. The NT and Distinguished
Names must be unique. However, not only is Display Name not required to be
unique, it is not even required to have a value. The error sounds to me like
you retrieved a value for Display Name, but the NameTranslate object was
unable to convert this to Distinguished Name because more than one object
had the specified Display Name. I think this would also happen if Display
Name has no value.
Revised code could be:
===============
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
strNetBIOSDomain = "hsi"
Set WshNetwork = CreateObject("Wscript.Network")
'strNTName = "jbrown"
strNTName = WshNetwork.username
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
Set objUser = GetObject ("LDAP://" & strUserDN)
strTelephoneNumber = objUser.Get("telephoneNumber")
Wscript.Echo Right(strTelephoneNumber, 4)
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"Al" <Al@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B04018BC-DC9A-46B4-B7B9-709C5FB7054F@xxxxxxxxxxxxxxxx
I have just tried using ths script and it works fine but once I when I
replaced
'strNTName = "jbrown"
with
strNTName = WshNetwork.username
I got an error "Name Translation: input name mapped to more than one
output
name"
'--------The code -----------
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_DISPLAY = 4
Const ADS_NAME_TYPE_1779 = 1
strNetBIOSDomain = "hsi"
'strNTName = "jbrown"
strNTName = WshNetwork.username
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strDisplay = objTrans.Get(ADS_NAME_TYPE_DISPLAY)
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_DISPLAY, strDisplay
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
Set objUser = GetObject ("LDAP://" & strUserDN)
objUser.GetInfo
strTelephoneNumber = objUser.Get("telephoneNumber")
Wscript.Echo Right(strTelephoneNumber, 4)
.
- Prev by Date: Re: Password Last Reset
- Next by Date: Re: Object Browser
- Previous by thread: Re: Advice on how to use a Type Library
- Next by thread: Re: Object Browser
- Index(es):
Relevant Pages
|