This is actually the same problem as with this thread: Security ID Structure Invalid , Getting this error when setting the new SecurityDescriptor for AD user properties however i am using C++ rather than .Internet.

I wish to set the flag "User Cannot Change Password" to have an Active Directory account. I'm by using this code from MS:

However I have an error: The safety ID structure is invalid.

This occurs within the method SetUserCannotChangePassword() only at that line:

//update the security descriptor property
hr = pads->Put(sbstrSecDesc, svar);

This error only occurs when I test this from the computer that's not within the same domain because the user I wish to set the AD flag. Basically run my application on a single domain when i modify everything works fine.

In regards to this error code I discovered the content:

The recommendation of opening the ports for LSA didn't work - I deactivated the fire walls but that didn't repair the problem.

Any suggestions?