p.c*_*ell 34 c# active-directory asp.net-3.5
请考虑此代码尝试创建Active Directory帐户.它在这里使用一组数据生成异常.目前尚不清楚导致异常的原因.
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
Run Code Online (Sandbox Code Playgroud)

用户代码未处理PrincipalOperationException:连接到系统的设备无法运行
导致此异常的原因是什么,您如何解决这个问题?
Ger*_*erm 68
sAMAccountName属性必须少于20个字符.