Converting a computer name from NT Name to ADSI Name

Converting a computer name from NT Name to ADSI Name

Post by Bruno Madie » Wed, 23 Jan 2002 00:11:23



Hi all,

First, thanks to Wayne Tilton for his vb Code in a previous mail.
I used his code to convert user names from NT4 to ADSI, and it's ok.
I'm now trying to make the same thing with computer names and it doesn't
work. Error : Name not found

Do you know why ?

Thanks
Bruno

My code :

   Option Explicit
   Dim Domain, NTDomain, nto, AdObj, AdsPath

   Const ADS_NAME_TYPE_1779 = 1
   Const ADS_NAME_TYPE_NT4 = 3
   Const ADS_NAME_INITTYPE_GC = 3

   ' Get name to be translated (wo/NT domain)
   AdObj = "MyComputer"

   ' Get the LDAP default naming context so we can bind to the GC
   Domain = GetObject("LDAP://RootDSE").Get("DefaultNamingContext")

   ' Get the NT style Domain name for the NT4 lookup
   NTDomain = GetObject("LDAP://" & Domain).dc

   ' Create name translate object and connect to GC for translations
   Set nto = CreateObject("NameTranslate")
   nto.Init ADS_NAME_INITTYPE_GC, Domain

   ' Set nto w/NT style domain\user
   nto.Set ADS_NAME_TYPE_NT4, NTDomain & "\" & AdObj

   ' Get RFC1779 (LDAP) name translation
   AdsPath = nto.Get(ADS_NAME_TYPE_1779)

 
 
 

Converting a computer name from NT Name to ADSI Name

Post by Marc Scheune » Fri, 25 Jan 2002 04:16:30


On Mon, 21 Jan 2002 16:11:23 +0100, "Bruno Madier"


>First, thanks to Wayne Tilton for his vb Code in a previous mail.
>I used his code to convert user names from NT4 to ADSI, and it's ok.
>I'm now trying to make the same thing with computer names and it doesn't
>work. Error : Name not found

Maybe because the computer accounts are stored under the pre-defined

LDAP://myserver/cn=ComputerName,ou=Computers,dc=domain,dc=com

container?

Marc

 
 
 

Converting a computer name from NT Name to ADSI Name

Post by Wayne Tilt » Fri, 25 Jan 2002 06:04:36


I know why...computer names have a $ sign at the end. So instead of
"MyComputer" you need "MyComputer$".   Tested and verified.

Wayne



>Hi all,

>First, thanks to Wayne Tilton for his vb Code in a previous mail.
>I used his code to convert user names from NT4 to ADSI, and it's ok.
>I'm now trying to make the same thing with computer names and it doesn't
>work. Error : Name not found

>Do you know why ?

>Thanks
>Bruno

Standard Disclaimer: I said it, they didn't, so blame me, not them!
Spam Avoidance: My reply address is invalid to confuse the spambots.
You can reach me at 'Wayne_Tilton at yahoo dot com'
 
 
 

Converting a computer name from NT Name to ADSI Name

Post by Max L. Vaug » Sat, 26 Jan 2002 00:30:54


Its important to remember some of the legacy NT 4 stuff when working with computers and their accounts in the AD.  When you create a computer account, the
samaccountname should always include the "$" suffix.  When you build an WinNT path, you are building an NT style name, Domain\userID, in this case the
computer account NT style name would be "domain\Computer$" for the WinNT provider.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support

Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.