title: LookupAccountName error when ReferencedDomainName is NULL
body: <p>If I do not save the optional <code>ReferencedDomainName</code> in a variable, the function returns <code>false</code> and I can no retrieve the used Sid. If the doc says it's optional, why do I need to include that as well? Here is my code:</p>
  
  <p>This works and returns a SID:</p>
  
  <pre><code>    DWORD size;
      TCHAR lpAccountName[USERNAME_SIZE];
      PSID Sid = (PSID)LocalAlloc(LPTR, SECURITY_MAX_SID_SIZE);
      LPSTR DomainName = (LPSTR)LocalAlloc(LPTR, sizeof(TCHAR) * 1024);
      DWORD cbSid = SECURITY_MAX_SID_SIZE;
      LPSTR userSIDBuffer = (LPSTR)LocalAlloc(LPTR, sizeof(TCHAR) * cbSid);
      SID_NAME_USE peUse;
  
      size = USERNAME_SIZE;
      if (!GetUserName(lpAccountName, &amp;size))
      {
          _error("Could not retrieve username.");
      }
  
      printf("Username found: %s\n", lpAccountName);
  
      size = 1024;
      if (!LookupAccountName(NULL, lpAccountName, Sid, &amp;cbSid, DomainName, &amp;size, &amp;peUse))
      {
          _error("Could not look up account.");
      }
  
      return Sid;
  </code></pre>
  
  <p>But If I remove the <code>DomainName</code> and change the <code>size=0</code> as per MSDN Documentation, I get a 122 error and no <code>Sid</code> is returned;</p>
  
  <pre><code>        size = 0;
          if (!LookupAccountName(NULL, lpAccountName, Sid, &amp;cbSid, NULL, &amp;size, &amp;peUse))
          {
              _error("Could not look up account.");
          }
  </code></pre>