Re: How to get encrypted user password
Re: How to get encrypted user password
- Subject: Re: How to get encrypted user password
- From: Dave Keck <email@hidden>
- Date: Wed, 30 Dec 2009 06:18:50 -1000
Directory Services being as painful of an API as it is, perhaps the
Security framework is a better route...
bool authenticateUser(const char *userName, const char *password)
{
AuthorizationRef authRef = nil;
AuthorizationRights authRights;
AuthorizationEnvironment authEnvironment;
AuthorizationItem authRightItems[1],
authEnvironmentItems[2];
OSStatus authResult = 0;
bool result = false;
assert(userName && strlen(userName));
assert(password);
authRightItems[0].name = "system.login.tty";
authRightItems[0].value = nil;
authRightItems[0].valueLength = 0;
authRightItems[0].flags = 0;
authRights.items = authRightItems;
authRights.count = 1;
authEnvironmentItems[0].name = kAuthorizationEnvironmentUsername;
authEnvironmentItems[0].value = (void *)userName;
authEnvironmentItems[0].valueLength = strlen(userName);
authEnvironmentItems[0].flags = 0;
authEnvironmentItems[1].name = kAuthorizationEnvironmentPassword;
authEnvironmentItems[1].value = (void *)password;
authEnvironmentItems[1].valueLength = strlen(password);
authEnvironmentItems[1].flags = 0;
authEnvironment.items = authEnvironmentItems;
authEnvironment.count = 2;
authResult = AuthorizationCreate(&authRights, &authEnvironment,
kAuthorizationFlagDefaults, &authRef);
if (authResult != errAuthorizationSuccess || !authRef)
goto cleanup;
result = true;
cleanup:
{
if (authRef)
AuthorizationFree(authRef, kAuthorizationFlagDefaults),
authRef = nil;
}
return result;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden