title: Getting "The security ID structure is invalid" while setting AD flag
body: <p>This is the same issue as in this thread: <a href="https://stackoverflow.com/questions/5946150">Security ID Structure Invalid , Getting this error when setting the new SecurityDescriptor for AD user properties</a> but I am using C++ instead of .Net.</p>
  
  <p>I want to set the flag "User Cannot Change Password" for an Active Directory account. I am using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa746398%28v=vs.85%29.aspx" rel="nofollow noreferrer">this code from MS</a> but get an error</p>
  
  <blockquote>
    <p>The security ID structure is invalid.</p>
  </blockquote>
  
  <p>This happens in the method <code>SetUserCannotChangePassword()</code> at this line:</p>
  
  <pre><code>//update the security descriptor property
  hr = pads-&gt;Put(sbstrSecDesc, svar);
  </code></pre>
  
  <p><strong>This error only happens when I test this from a computer that is not in the same domain as the user I want to set the AD flag. If I run my app on the same domain as I modify everything works fine.</strong></p>
  
  <p>Regarding this error code <a href="http://support.microsoft.com/kb/948502/en-us" rel="nofollow noreferrer">I found this article</a>. The advice of opening the ports for LSA did not work - I deactivated the firewalls but that did not fix the problem.</p>
  
  <p>And I only have that problem with setting this flag. Other flags as "UserMustChangePassword" are no problem.</p>
  
  <p>Any suggestions?</p>