有没有办法改变本地帐户的标准20个字符的UserName最大长度限制?
(Server 2008 R2具体)
不,它是固定的20.我相信这是出于向后兼容的原因。 您可以在Active Directory中更大(SAMAccountName字段除外),但不能在本地。
您必须引用sam-accountname属性。 login名称必须遵循以下规则:
login名称的规则
login名称必须遵循以下规则:
本地login名在工作站上必须是唯一的,全局login名在整个域中必须是唯一的。
login名称最多可以有104个字符。 但是,使用超过64个字符的login名是不实际的。
一个Microsoft Windows NT版本4.0或更早版本的login名被授予所有帐户,默认情况下它被设置为Windows 2000login名的前20个字符。 Windows NT版本4.0或更早版本的login名称在整个域中必须是唯一的。
无论域操作模式如何,从Windows 2000计算机login到域的用户都可以使用其Windows 2000login名或Windows NT版本4.0或更早版本的login名。
请注意,GUI只允许您创build20个字符名称,您将不得不以编程方式创build它们以获得20个字符。
“请注意,GUI只允许您创build20个字符的名称,您将不得不以编程方式创build它们才能超过20个字符。”
我会说这个说法是不正确的。 我无法以编程方式创build大于二十个字符的用户名。 以下是我在Windows Server 2008 R2上运行的相关VB.NET代码。 它用于创build20个或更less字符的用户名,但如果用户名超过20个字符则会引发exception。 亲自尝试一下。 此致Joseph Davoli
码:
Imports System.DirectoryServices'使我们能够访问目录服务。
函数Blah()随便什么
Dim strFNMILN As String =“Christopher.B.Robinson”'注意:二十二个字符。
Dim strFullName as string =“Christopher B. Robinson”
'声明一个新的“DirectoryEntry”对象variables并为其分配条目
'这台电脑(运行这个代码的电脑)。
Dim DirectoryEntryThisComputer As New DirectoryEntry(“WinNT://”&Environment.MachineName&“,computer”)
'声明一个新的“DirectoryEntry”对象variables,并将其命名为“DirectoryEntryNewUser”。
'在本地目录中创build一个新用户,并将该用户分配给我们的对象variables。
Dim DirectoryEntryNeUUser DirectoryEntry = DirectoryEntryThisComputer.Children.Add(strFNMILN,“user”)
'添加此用户的全名。
DirectoryEntryNeUUser.Invoke(“Put”,New Object(){“fullname”,strFullName})
'添加描述值。
DirectoryEntryNeUUser.Invoke(“Put”,New Object(){“description”,“这是一个testing用户”)}
'为新用户设置密码(最less14个字符)。
DirectoryEntryNeUUser.Invoke(“SetPassword”,New Object(){“abcdefg1234567”})
'将这个新用户保存到本地目录(本机的目录)。
DirectoryEntryNewUser.CommitChanges()
。
。
结束function
我将DSADD用于W2K3 AD服务器,由于“SAMID”字符长度为21(21)而失败。
C:\Users\admin-of-change>DSAdd.exe user "CN=SharePoint Service Applications XYZ,OU=Users,OU=District UVW,OU=XYZ,DC=domain-universe,DC=int,DC=net" -samid "adm_xyz_SPServiceApps" -upn [email protected] -fn "SharePoint Service Applications" -ln "XYZ" -display "SharePoint Service Applications XYZ" -pwd "continue2013" -desc "Non Human Account" -office "Head Office" -email [email protected] -webpg "www.UnusualCompany.com" -title "SharePoint Service Applications XYZ" -company "XYZ" -disabled no dsadd failed:CN=SharePoint Service Applications XYZ,OU=Users,OU=District UVW,OU=XYZ,DC=domain-universe,DC=int,DC=net:The name provided is not a properly formed account name. type dsadd /? for help. ┌─────────────────────────────────────┐ │ Executed Tue 07/02/2013 13:59:57.88 │ As [admin-of-change] └─────────────────────────────────────┘
在减lessUPN的时候解决了。
C:\Users\admin-of-change>DSAdd.exe user "CN=SharePoint Service Applications XYZ,OU=Users,OU=District UVW,OU=XYZ,DC=domain-universe,DC=int,DC=net" -samid "adm_xyz_SPSvcApps" -upn [email protected] -fn "SharePoint Service Applications" -ln "XYZ" -display "SharePoint Service Applications XYZ" -pwd "continue2013" -desc "Non Human Account" -office "Head Office" -email [email protected] -webpg "www.UnusualCompany.com" -title "SharePoint Service Applications XYZ" -company "XYZ" -disabled no dsadd succeeded:CN=SharePoint Service Applications XYZ,OU=Users,OU=Users,OU=District UVW,OU=XYZ,DC=domain-universe,DC=int,DC=net ┌─────────────────────────────────────┐ │ Executed Tue 07/02/2013 14:06:21.08 │ As [admin-of-change] └─────────────────────────────────────┘
任何改进的意见,欢迎。