title: How verify account's password
body: <p>I am asking account's password(password for login in mac) in my application. How can I verify password which is entered user?</p>
  
  <p>I think something like it, but it doesn't work:</p>
  
  <pre><code>-(BOOL)authenticatePassword:(char *)password adminName:(char *)userName
  {
  
      BOOL retValue = NO;
  
      OSStatus status,status1;
      AuthorizationFlags flag;
      AuthorizationItem items[2];
      items[0].name = kAuthorizationEnvironmentPassword;
      items[0].value = password;
      items[0].valueLength = strlen(password);
      items[0].flags = 0;
  
      items[1].name = kAuthorizationEnvironmentUsername;
      items[1].value = userName;
      items[1].valueLength = strlen(userName);
      items[1].flags = 0;
  
      AuthorizationItemSet itemSet = {2,items};
      status = AuthorizationCreate(NULL, &amp;itemSet, kAuthorizationFlagDefaults, &amp;authorization_);
      if(status == errAuthorizationSuccess) {
          AuthorizationRights rights = {2,&amp;items};
          //AuthorizationEnvironment kEnviroment = {2, items};
          AuthorizationFlags flag1 = kAuthorizationFlagDefaults;
          status1 = AuthorizationCopyRights(authorization_, &amp;rights,NULL, flag1, NULL);
  
          if(status1 == errAuthorizationSuccess) {
              retValue = YES;
          }
      }
  
      return retValue;
  
  }
  </code></pre>