DirectoryEntry ObjectSecurity null引用异常

时间:2012-02-13 21:15:17

标签: c# directoryentry

我尝试使用此代码启用Windows帐户,但在此行中的ObjectSecurity(Null引用)中有异常ActiveDirectorySecurity userSecurity = user.ObjectSecurity;

1 个答案:

答案 0 :(得分:1)

我怀疑你的错误将出现在代码的第5行

user.Properties["userAccountControl"].Value = val & ~0x2; //this will error

如果您要调试它,您可能会看到以下错误

错误指针和固定大小的缓冲区只能在不安全的上下文中使用