WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Translate NT Name to LDAP Path

 Keywords: AD ADSI Active Directory Translate Convert NetBIOS NT Name LDAP Path NameTranslate Object Distinguished ADS_NAME_TYPE_NT4

; If you have the NT Name of the user and the NetBIOS name of the domain you
; can use the NameTranslate object to retrieve the Distinguished Name required
; for the LDAP provider.

ADS_NAME_INITTYPE_GC = 3
ADS_NAME_TYPE_NT4 = 3
ADS_NAME_TYPE_1779 = 1

strDomain = "TestDom" ; !!! Modify To Fit Your Needs !!!

; Specify the NetBIOS name of the domain and the NT name of the user.
;strNTName = "Domain\User"
AddExtender("WWWNT34i.DLL")
acct_list = wntAcctList( strDomain, 1, 1)
strNTName = AskItemlist("List of users with accounts on an NT server.", acct_list,@TAB,@SORTED,@SINGLE)

; Use the NameTranslate object to convert the NT user name to the
; Distinguished Name required for the LDAP provider.
objTrans = CreateObject("NameTranslate")

; Initialize NameTranslate by locating the Global Catalog.
objTrans.Init( ADS_NAME_INITTYPE_GC, "" )
; Use the Set method to specify the NT format of the object name.
objTrans.Set( ADS_NAME_TYPE_NT4, strNTName )

; Use the Get method to retrieve the RPC 1779 Distinguished Name.
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

; Bind to the user object in Active Directory with the LDAP provider.
objUser = GetObject("LDAP://" : strUserDN)

Pause( strNTName, strUserDN )

Article ID:   W17554
Filename:   Translate NT Name to LDAP Path.txt
File Created: 2010:04:16:10:44:32
Last Updated: 2010:04:16:10:44:32