if (isset($ini_array["APIAccountID"])) {
     $APIAccountID = $ini_array["APIAccountID"];
 }
 if (isset($ini_array["APIHost"])) {
     $APIHost = $ini_array["APIHost"];
 }
 if (!isset($username) || !isset($password) || !isset($APIAccountID) || !isset($APIHost)) {
     $_SESSION["errorMessage"] = "Please make sure credentials are set (in credentials.php).";
     header("Location: error.php");
     die;
 }
 // setup credential api - we only use this when logging in s
 $creds_endpoint = $APIHost . "/api/3.0/Credential.asmx";
 $creds_wsdl = "api/CredentialService.wsdl";
 $creds_options = array('location' => $creds_endpoint, 'trace' => true, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
 $credService = new CredentialService($creds_wsdl, $creds_options);
 // login
 $login = new Login();
 $login->Email = $username;
 $login->Password = $password;
 try {
     $response = $credService->Login($login);
 } catch (SoapFault $fault) {
     $_SESSION["errorMessage"] = $fault;
     //$_SESSION["lastRequest"] = $api->_lastRequest;
     header("Location: error.php");
     die;
 }
 // verify that the API AccountID in the creds file is linked to this user
 $bfound = false;
 foreach ($response->LoginResult->Accounts->Account as $account) {
function loginSample()
{
    global $UserID, $Password, $IntegratorsKey;
    $options = array('location' => "https://demo.docusign.net/api/3.0/credential.asmx", 'trace' => true, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
    $credApi = new CredentialService("api/CredentialService.wsdl", $options);
    $loginParams = new Login();
    $loginParams->Email = "[" . $IntegratorsKey . "]" . $UserID;
    $loginParams->Password = $Password;
    $response = $credApi->Login($loginParams);
    return $response;
}
Example #3
0
function login($user, $password)
{
    $retval = false;
    //
    $_SESSION["lastLoginError"] = "";
    global $creds_wsdl, $creds_options;
    $credService = new CredentialService($creds_wsdl, $creds_options);
    $login = new Login();
    $login->Email = $user;
    $login->Password = $password;
    try {
        $response = $credService->Login($login);
    } catch (SoapFault $fault) {
        $_SESSION["errorMessage"] = $fault;
        header("Location: error.php");
        die;
    }
    switch ($response->LoginResult->ErrorCode) {
        case "User_Does_Not_Exist_In_System":
            $retval = false;
            $_SESSION["lastLoginError"] = "Login failed.";
            break;
        case "Account_Lacks_Permissions":
            $retval = false;
            $_SESSION["lastLoginError"] = "Your account does not have permission to log in.";
            break;
        case "User_Lacks_Permissions":
            $retval = false;
            $_SESSION["lastLoginError"] = "Your user does not have permission to log in.";
            break;
        case "User_Authentication_Failed":
            $retval = false;
            $_SESSION["lastLoginError"] = "Login failed.";
            break;
        case "Unspecified_Error":
            $retval = false;
            $_SESSION["lastLoginError"] = "An error occurred.";
            break;
        case "Success":
            $AccountsWithTemplateAccess = checkAccountsForTemplatePermissions($response->LoginResult, $user, $password);
            if (count($AccountsWithTemplateAccess > 0)) {
                $_SESSION["AccountID"] = $AccountsWithTemplateAccess[0]->AccountID;
                $_SESSION["AccountName"] = $AccountsWithTemplateAccess[0]->AccountName;
                $_SESSION["UserName"] = $AccountsWithTemplateAccess[0]->UserName;
                $_SESSION["Email"] = $AccountsWithTemplateAccess[0]->Email;
                $_SESSION["UserID"] = $AccountsWithTemplateAccess[0]->UserID;
                $_SESSION["Password"] = $password;
                // If we have more than one account, store them so we can show them in the account selector
                if (count($AccountsWithTemplateAccess > 1)) {
                    $_SESSION["Accounts"] = $AccountsWithTemplateAccess;
                }
            } else {
                $retval = false;
                $_SESSION["lastLoginError"] = "None of your accounts have Manage Template permissions. You can correct this in the Member Console";
            }
            $retval = true;
            break;
        default:
            $retval = false;
    }
    return $retval;
}