• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Authenticate Password.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Authenticate Password.


  • Subject: Authenticate Password.
  • From: Macarov Anatoli <email@hidden>
  • Date: Mon, 28 Jul 2008 07:24:08 -0700 (PDT)

HI!!!
Cocoa, Obj-C.

With the help of this procedure I check whether the password has been entered correctly. But the code works only for the user with admins rights. How do I check the password being a standard user?

Cod:
-(BOOL) authenticatePassword:(NSString *)password :(NSString *)userName
{
AuthorizationRef authorization;
    OSStatus status,status1;
    AuthorizationFlags Flags;
    AuthorizationItem envItems[2];
return YES;
    envItems[0].name = kAuthorizationEnvironmentPassword;
    envItems[0].value = [password cStringUsingEncoding:NSUTF8StringEncoding];
    envItems[0].valueLength = strlen([password cStringUsingEncoding:NSUTF8StringEncoding]);
    envItems[0].flags = 0;

    envItems[1].name = kAuthorizationEnvironmentUsername;
    envItems[1].value = [userName cStringUsingEncoding:NSUTF8StringEncoding];
    envItems[1].valueLength = strlen([userName cStringUsingEncoding:NSUTF8StringEncoding]);
    envItems[1].flags = 0;

    AuthorizationItemSet env = { 2, envItems };

    status = AuthorizationCreate(NULL, &env, kAuthorizationFlagDefaults, &authorization);
    if (status != errAuthorizationSuccess) {
    NSLog(@"AuthorizationCreate NOT Success");
        return NO;
    }else{
        NSLog(@"AuthorizationCreate Success");
    }

    AuthorizationRights myRights = {2, &envItems};
    AuthorizationEnvironment kEnvironment = { 2, envItems };

    Flags = kAuthorizationFlagDefaults | kAuthorizationFlagExtendRights;
    status1 = AuthorizationCopyRights (authorization,&myRights, &kEnvironment, Flags, NULL );
       
    if (status1 != errAuthorizationSuccess) {
        NSLog(@"AuthorizationCopyRights NOT Success");
        return NO;
    }else{
        NSLog(@"AuthorizationCopyRights Success");
        return YES;
    }
    return NO;
}




      ________________________________________________________
Вы уже с Yahoo!?
Испытайте обновленную и улучшенную. Yahoo! Почту! http://ru.mail.yahoo.com
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Authenticate Password.
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: NSTextView + other NSView in NSScrollView?
  • Next by Date: Re: NSTextView + other NSView in NSScrollView?
  • Previous by thread: Re: How to get the cursor animation effects - Clouds of smoke when deleting something
  • Next by thread: Re: Authenticate Password.
  • Index(es):
    • Date
    • Thread