Re: NameTranslate object error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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)


.



Relevant Pages

  • Re: Parsing CSV files
    ... But that's a display technique, ... carry over from the days of teletype and paper terminals and we're just ... Note the operative word - Carriage! ... translations which may be default depending on the OS it connected to). ...
    (microsoft.public.vc.mfc)
  • Re: Adding records to table from a form, with pre-populated values
    ... subform should only display a new record row, ... So I have a query that gets me all (BaseTextID, Text, Language) ... missing translations I will have 200 rows, then someone will fill the 200 ... I think something like this will display the information: ...
    (microsoft.public.access.formscoding)
  • Re: Extracting letters by alphabetic order.
    ... would be to lookup whole words in your dictionary database and display the ... definitions or translations. ... website and display the results. ...
    (microsoft.public.word.vba.general)
  • Multilanguage website
    ... And I display the field that corresponds to the desired language ... some files contains all translations, where I include the good one: ...
    (alt.php)