MacOS - legal way to get admin password
===

I want to create application that use admin password to run sum scripts in bash. For example:
    
     echo **pass** | sudo -S reboot

What is the best way to get it.

I looked [this][1] tutorial, and all of what I understood - it is how to run authorization window.

    AuthorizationRef authRef= NULL;
    AuthorizationItem right = { "com.my.app", 0, NULL, 0 };
    AuthorizationRights rightSet = { 1, &right };
    OSStatus status;
    
    if (AuthorizationCreate(
                            NULL, 
                            kAuthorizationEmptyEnvironment,
                            kAuthorizationFlagDefaults, 
                            &authRef) != errAuthorizationSuccess)
    {
        NSLog(@"Could not create authorization reference object.");
    }
    
    status = AuthorizationCopyRights(authRef, &rightSet, kAuthorizationEmptyEnvironment, 
                                     kAuthorizationFlagDefaults |
                                     kAuthorizationFlagPreAuthorize |
                                     kAuthorizationFlagInteractionAllowed | 
                                     kAuthorizationFlagExtendRights,
                                     NULL);

Is there a way to get password after this steps?

Or all of this wrong  - and exist another way?

Thanks!


  [1]: https://developer.apple.com/library/mac/#documentation/Security/Conceptual/authorization_concepts/01introduction/introduction.html#//apple_ref/doc/uid/TP30000995-CH204-TP1