Question

I try to enable windows account with this code but i ve exception in ObjectSecurity (Null reference) in this line ActiveDirectorySecurity userSecurity = user.ObjectSecurity;

Was it helpful?

Solution

I would suspect that your error would be on the 5th line in the code

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

and if you were to debug it you would probably see the following error

Error Pointers and fixed size buffers may only be used in an unsafe context

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top