netbiosDomain\samAccountName
distinguishedName
.
有两个子域:
*
DC=northeast,DC=domain,DC=com
DC=southeast,DC=domain,DC=com
有两个不同的用户:
-
NORTHEAST\NICKD
=
CN=nickd,CN=Users,DC=northeast,DC=domain,DC=com
-
SOUTHEAST\NICKD
CN=nickd,CN=Users,DC=southeast,DC=domain,DC=com
鉴于
东北\NICKD
CN=nickd,CN=Users,DC=northeast,DC=domain,DC=com
?
基本上,这个问题可以再问一次:如何查询LDAP以获得netbios域的distingushedName?
答案在这里
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/dbbeeefd-001b-4d1d-93cb-b44b0d5ba155/how-do-you-search-for-a-domain-samaccountname-in-active-directory?forum=winserverDS&prof=required
提供可以执行此操作的vbscript和powershell命令。但是我需要一个LDAP查询来完成它。或者任何可以从Java跨平台调用的东西。
下面是可以转换的vbscript
northeast\nickd
进入之内
CN=nickd,CN=Users,DC=northeast,DC=domain,DC=com
:
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
' Specify the NetBIOS name of the domain.
strNetBIOSDomain = "northeast"
' Specify the NT name of the user.
strNTName = "nickd"
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
Set 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, strNetBIOSDomain & "\" & strNTName
' Use the Get method to retrieve the RFC 1779 Distinguished Name.
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
' Escape any "/" characters with backslash escape character.
' All other characters that need to be escaped will be escaped.
strUserDN = Replace(strUserDN, "/", "\/")
Wscript.Echo strUserDN
$Name = "northeast"
$Domain = "nickd"
$objTrans = New-Object -comObject "NameTranslate"
$objNT = $objTrans.GetType()
$objNT.InvokeMember("Init", "InvokeMethod", $Null, $objTrans, (3, $Null))
Try
{
$objNT.InvokeMember("Set", "InvokeMethod", $Null, $objTrans, (3, "$Domain\$Name"))
$DN = $objNT.InvokeMember("Get", "InvokeMethod", $Null, $objTrans, 1)
$DN
}
Catch
{
"Bad name: $Domain\$Name"
}
相关:
https://serverfault.com/questions/234041/can-an-ldap-query-on-ad-provide-the-netbios-domain-name-for-a-single-account-whe