Mat*_*ino 8 windows windows-server-2008 user-management
有没有办法更改本地帐户的标准 20 个字符用户名最大长度限制?
(具体是Server 2008 R2)
您必须指的是 sam-accountname 属性。登录名必须遵循以下规则:
登录名规则
登录名必须遵循以下规则:
本地登录名在工作站上必须是唯一的,全局登录名在整个域中必须是唯一的。
登录名最多可包含 104 个字符。但是,使用超过 64 个字符的登录名是不切实际的。
Microsoft Windows NT 4.0 或更早版本的登录名被赋予所有帐户,默认情况下设置为 Windows 2000 登录名的前 20 个字符。Windows NT 4.0 或更早版本的登录名在整个域中必须是唯一的。
无论域操作模式如何,从 Windows 2000 计算机登录到域的用户都可以使用其 Windows 2000 登录名或 Windows NT 4.0 或更早版本的登录名。
请注意,GUI 仅允许您创建 20 个字符名称,您必须以编程方式创建它们才能超过 20 个。
小智 5
“请注意,GUI 仅允许您创建 20 个字符名称,您必须以编程方式创建它们才能超过 20 个。”
我会说这种说法是不正确的。我无法以编程方式创建超过 20 个字符的用户名。下面是我在 Windows Server 2008 R2 上运行的相关 VB.NET 代码。它适用于创建 20 个或更少字符的用户名,但如果用户名超过 20 个字符,则会引发异常。自己试试吧。真诚的,约瑟夫·达沃利
代码:
Imports System.DirectoryServices 'Gives us access to Directory Services.Function Blah() As Whatever
Dim strFNMILN As String = "Christopher.B.Robinson" 'NOTE: Twenty-two characters. Dim strFullName as string = "Christopher B. Robinson"
'Declare a new "DirectoryEntry" object variable and assign to it the entry for 'this computer (the computer on which this code is running). Dim DirectoryEntryThisComputer As New DirectoryEntry("WinNT://" & Environment.MachineName & ",computer")
'Declare a new "DirectoryEntry" object variable and name it "DirectoryEntryNewUser". 'Create a new user in the local directory and assign that user to our object variable. Dim DirectoryEntryNewUser As DirectoryEntry = DirectoryEntryThisComputer.Children.Add(strFNMILN, "user")
'Add the fullname of this user. DirectoryEntryNewUser.Invoke("Put", New Object() {"fullname", strFullName })
'Add a description value. DirectoryEntryNewUser.Invoke("Put", New Object() {"description", "This is a test user."})
'Set the password for this new user (14 character minimum). DirectoryEntryNewUser.Invoke("SetPassword", New Object() {"abcdefg1234567"})
'Save this new user to the local directory (this machine's directory). DirectoryEntryNewUser.CommitChanges()
. . End Function