Thanks, for your suggestion, but the code sample fails. I also tried to change "StrMember. " to "StrMember," without any luck. I just ran the code in a VBScript file.
> Thanks, for your suggestion, but the code sample fails. I also tried to > change "StrMember. " to "StrMember," without any luck. > I just ran the code in a VBScript file.
> /Jesper
Sorry, I did that from memory and without testing. There is a typo and a missing argument (which you could have researched), but the concept is valid. Try this ..
> Sorry, I did that from memory and without testing. There is a typo > and a missing argument (which you could have researched), but the > concept is valid. Try this ..
> "Tom Lavedas" <tglba...@cox.net> skrev i meddelelsen > news:a59ec48a-62f6-49dc-8ec4-3524222d1c5f@l2g2000yqd.googlegroups.com... >> Sorry, I did that from memory and without testing. There is a typo >> and a missing argument (which you could have researched), but the >> concept is valid. Try this ..
However, note that the result is the "Common Name" of the user, not what most people call the username, unless the two values have been made always the same in your environment.
The value of the "cn" attribute is the Common Name of the object. It must be unique in the OU, but there can be several objects with the same Common Name as long as they are in different OU's or containers. The value of the sAMAccountName attribute is the "pre-Windows 2000 logon name" (on the "Account" tab of ADUC). This is also referred to as the userID, username, or NT name of the user. This must be unique in the domain.
If the cn and sAMAccountName attributes are always the same in your domain, you can parse the Distinguished Name of the user. Otherwise, you should use the NameTranslate object to convert the Distinguished Name into the sAMAccountName. See this link for details:
> However, note that the result is the "Common Name" of the user, not what > most people call the username, unless the two values have been made always > the same in your environment.
> The value of the "cn" attribute is the Common Name of the object. It must > be unique in the OU, but there can be several objects with the same Common > Name as long as they are in different OU's or containers. The value of the > sAMAccountName attribute is the "pre-Windows 2000 logon name" (on the > "Account" tab of ADUC). This is also referred to as the userID, username, > or NT name of the user. This must be unique in the domain.
> If the cn and sAMAccountName attributes are always the same in your > domain, you can parse the Distinguished Name of the user. Otherwise, you > should use the NameTranslate object to convert the Distinguished Name into > the sAMAccountName. See this link for details:
>> However, note that the result is the "Common Name" of the user, not what >> most people call the username, unless the two values have been made >> always the same in your environment.
>> The value of the "cn" attribute is the Common Name of the object. It must >> be unique in the OU, but there can be several objects with the same >> Common Name as long as they are in different OU's or containers. The >> value of the sAMAccountName attribute is the "pre-Windows 2000 logon >> name" (on the "Account" tab of ADUC). This is also referred to as the >> userID, username, or NT name of the user. This must be unique in the >> domain.
>> If the cn and sAMAccountName attributes are always the same in your >> domain, you can parse the Distinguished Name of the user. Otherwise, you >> should use the NameTranslate object to convert the Distinguished Name >> into the sAMAccountName. See this link for details:
> Thanks for the heads up. I will take a look at your great FAQ ressource.
> /Jesper
A quick example converting a DN into sAMAccountName: ======== Option Explicit
Dim strUserDN, objTrans, strUserName
' Constants for the NameTranslate object. Const ADS_NAME_INITTYPE_GC = 3 Const ADS_NAME_TYPE_NT4 = 3 Const ADS_NAME_TYPE_1779 = 1
' Specify user Distinguished Name. strUserDN = "CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"
' Use the NameTranslate object to convert Distinguished Name ' into sAMAccountName. Set objTrans = CreateObject("NameTranslate")
' Initialize NameTranslate by locating the Global Catalog. objTrans.Init ADS_NAME_INITTYPE_GC, "" ' Use the Set method to specify the Distinguished Name of the object. objTrans.Set ADS_NAME_TYPE_1779, strUserDN ' Use the Get method to retrieve the NT format of the name. ' This format is <NetBIOS-Domain-Name>\<sAMAccountName> strUserName = objTrans.Get(ADS_NAME_TYPE_NT4) ' Remove NetBIOS name of domain. strUserName = Mid(strUserName, InStr(strUserName, "\") + 1)
> ' Specify user Distinguished Name. > strUserDN = "CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"
> ' Use the NameTranslate object to convert Distinguished Name > ' into sAMAccountName. > Set objTrans = CreateObject("NameTranslate")
> ' Initialize NameTranslate by locating the Global Catalog. > objTrans.Init ADS_NAME_INITTYPE_GC, "" > ' Use the Set method to specify the Distinguished Name of the object. > objTrans.Set ADS_NAME_TYPE_1779, strUserDN > ' Use the Get method to retrieve the NT format of the name. > ' This format is <NetBIOS-Domain-Name>\<sAMAccountName> > strUserName = objTrans.Get(ADS_NAME_TYPE_NT4) > ' Remove NetBIOS name of domain. > strUserName = Mid(strUserName, InStr(strUserName, "\") + 1)