auth::get_local_account (private)

 auth::get_local_account [ -return_url return_url ] -username username \
    [ -authority_id authority_id ] [ -email email ] \
    [ -first_names first_names ] [ -last_name last_name ]

Defined in packages/acs-authentication/tcl/authentication-procs.tcl

Get the user_id of the local account for the given username and domain combination.

Switches:
-return_url (optional)
-username (required)
The username to find
-authority_id (optional)
The ID of the authority to ask to verify the user. Leave blank for local authority.
-email (optional)
-first_names (optional)
-last_name (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 auth::authenticate auth::authenticate (public) auth::get_local_account auth::get_local_account auth::authenticate->auth::get_local_account _ _ (public) auth::get_local_account->_ acs_user::get acs_user::get (public) auth::get_local_account->acs_user::get acs_user::get_by_username acs_user::get_by_username (public) auth::get_local_account->acs_user::get_by_username acs_user::get_user_info acs_user::get_user_info (public) auth::get_local_account->acs_user::get_user_info ad_html_text_convert ad_html_text_convert (public) auth::get_local_account->ad_html_text_convert

Testcases:
No testcase defined.
Source code:
    array set auth_info [list]

    # Will return:
    #   auth_info(account_status)
    #   auth_info(account_message)
    #   auth_info(user_id)

    if { $authority_id eq "" } {
        set authority_id [auth::authority::local]
    }
    #ns_log notice "auth::get_local_account authority_id = '${authority_id}' local = [auth::authority::local]"
    ad_try {
        acs_user::get -authority_id $authority_id -username $username -array user
        set account_found_p 1
    } on error {errorMsg} {
        set account_found_p 0
    }
    if { !$account_found_p } {

        # Try for an on-demand sync
        array set info_result [auth::user_info::GetUserInfo  -authority_id $authority_id  -username $username]

        if {$info_result(info_status) eq "ok"} {

            array set user $info_result(user_info)

            if {$email ne ""
                && (![info exists user(email)] || $user(email) eq "")
            } {
                set user(email) $email
            }
            if {$first_names ne ""
                && (![info exists user(first_names)] || $user(first_names) eq "")
            } {
                set user(first_names) $first_names
            }
            if {$last_name ne ""
                && (![info exists user(last_name)] || $user(last_name) eq "")
            } {
                set user(last_name) $last_name
            }
            array set creation_info [auth::create_local_account  -authority_id $authority_id  -username $username  -array user]

            if {$creation_info(creation_status) ne "ok"} {
                set auth_info(account_status) "closed"
                # Used to get help contact info
                auth::authority::get -authority_id $authority_id -array authority
                set system_name [ad_system_name]
                set auth_info(account_message) "You have successfully authenticated, but we were unable to create an account for you on $system_name. "
                set auth_info(element_messages) $creation_info(element_messages)
                append auth_info(account_message) "The error was: $creation_info(element_messages). Please contact the system administrator."

                if { $authority(help_contact_text) ne "" } {
                    append auth_info(account_message) "<p><h3>Help Information</h3>"
                    append auth_info(account_message) [ad_html_text_convert  -from $authority(help_contact_text_format)  -to "text/html" -- $authority(help_contact_text)]
                }
                return [array get auth_info]
            }

        } else {

            # Local user account doesn't exist
            set auth_info(account_status) "closed"

            # Used to get help contact info
            auth::authority::get -authority_id $authority_id -array authority
            set system_name [ad_system_name]
            set auth_info(account_message) [_ acs-subsite.Success_but_no_account_yet]

            if { $authority(help_contact_text) ne "" } {
                append auth_info(account_message) [_ acs-subsite.Help_information]
                append auth_info(account_message) [ad_html_text_convert  -from $authority(help_contact_text_format)  -to "text/html" -- $authority(help_contact_text)]
            }

            return [array get auth_info]
        }
    }

    set user_id [acs_user::get_by_username  -authority_id $authority_id -username $username]
    set user_info [acs_user::get_user_info -user_id $user_id]
    set party_info [party::get -party_id $user_id]

    # Check local account status
    array set auth_info [auth::check_local_account_status  -user_id $user_id  -authority_id      [dict get $user_info authority_id]  -member_state      [dict get $user_info member_state]  -email             [dict get $party_info email]  -email_verified_p  [dict get $user_info email_verified_p]  -screen_name       [dict get $user_info screen_name]  -password_age_days [dict get $user_info password_age_days]  -return_url $return_url]

    # Return user_id
    set auth_info(user_id) $user_id

    return [array get auth_info]
Generic XQL file:
packages/acs-authentication/tcl/authentication-procs.xql

PostgreSQL XQL file:
packages/acs-authentication/tcl/authentication-procs-postgresql.xql

Oracle XQL file:
packages/acs-authentication/tcl/authentication-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: