每当我尝试将 UserPrincipal 保存到 Active Directory 并且 UserPrincipalName 或 EmailAddress 长度超过 20 个字符时, UserPrincipal.Save 方法将抛出以下错误:
'System.DirectoryServices.AccountManagement.PrincipalOperationException' A device attached to the system is not functioning active
如何保存长度超过 20 个字符的电子邮件地址?
请您参考如下方法:
只要未指定 SamAccountName,UserPrincipal.Name 就会被复制到 UserPrincipal.SamAccountName。
当 UserPrincipal.Name 超过 20 个字符时,这当然会抛出异常。在这种情况下,一个奇怪的。要解决此问题,我必须在保存到少于 20 个字符之前手动设置 SamAccountName。
