creating a user in Active Directory: A device attached to the system is not functioning

為{幸葍}努か 提交于 2019-11-27 00:34:07

问题


Consider this code attempting to create an Active Directory account. It's generating an exception here with a certain set of data. It's not clear right now what's causing the exception.

 var user = new UserPrincipal(someValidUserContext,
                              ".x-xyz-t-FooFooBarTest", "somePwd", true);

 user.UserPrincipalName = ".x-xyz-t-FooFooBarTest@foobarbatbaz.net";
 user.SamAccountName = ".x-xyz-t-FooFooBarTest";         
 user.DisplayName = "Some String 16 chars long";
 user.Name =  "Some String 16 chars long";
 user.Description = "Foo BarBaz 12 more characters";
 user.AccountExpirationDate = someDateInFuture;
 user.UserCannotChangePassword = true;
 user.Save();

 // exception thrown on Save(): 
 // A device attached to the system is not functioning

PrincipalOperationException was unhandled by user code: A device attached to the system is not functioning

What's causing this exception, and how can you work around it?


回答1:


The sAMAccountName attribute must be 20 characters or less.



来源:https://stackoverflow.com/questions/3095510/creating-a-user-in-active-directory-a-device-attached-to-the-system-is-not-func

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!