Windows Server 2008/R2:更改最大使用者名稱長度?

Windows Server 2008/R2:更改最大使用者名稱長度?

有沒有辦法更改本機帳戶的標準 20 個字元使用者名稱最大長度限制?

(具體為Server 2008 R2)

答案1

不,它固定為 20。您可以在 Active Directory 中進行更大的操作(SAMAccountName 欄位除外),但不能在本機上進行操作。

答案2

您必須引用 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 個。

答案3

“請注意,GUI 只允許您創建 20 個字元名稱,您必須以程式設計方式創建它們才能超過 20 個。”

我想說這個說法是不正確的。我無法以程式設計方式建立超過二十個字元的使用者名稱。以下是我在 Windows Server 2008 R2 上執行的相關 VB.NET 程式碼。它適用於創建二十個或更少字符的用戶名,但如果用戶名超過二十個字符,則會引發異常。自己嘗試一下。此致 約瑟夫·達沃利

代碼:

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

答案4

我正在 W2K3 AD Server 中使用 DSADD,但由於“SAMID”的長度為 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 "X Y Z" -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]
└─────────────────────────────────────┘

減小UPN即可解決。

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 "X Y Z" -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]
└─────────────────────────────────────┘

歡迎提出任何改進意見。

相關內容