PreviousNext

Example of a System Login Program

Following is an example of a system login program that obtains a login context that can be trusted for both network and local operations.

Note: One of the function calls that appears in the following example, sec_login_purge_context( ), is described in Releasing and Purging a Context.

if (sec_login_setup_identity(principal,sec_login_no_flags,

&login_context,&st))

{

...get password...

if (sec_login_valid_and_cert_ident(login_context, password,

&reset_passwd, &auth_src,&st))

{

if(auth_src==sec_login_auth_src_network)

{

if (GOOD_STATUS(&st)

sec_login_set_context(login_context);

}

}

if (reset_passwd)

{

...reset the user's password...

if (passwd_reset_fails)

{

sec_login_purge_context(login_context)

...application login-failure actions...

}

...application-specific login-valid actions...

}

}