Esempio n. 1
1
 function adicionaUsuario($nome, $login, $senha)
 {
     // Get the API client and construct the service object.
     $sobrenome = '-';
     $arrayNome = explode(" ", $nome);
     if (count($arrayNome) > 1) {
         $sobrenome = $arrayNome[1];
     }
     $client = $this->getClient();
     $service = new Google_Service_Directory($client);
     $postBody = new Google_Service_Directory_User();
     $postBody->setPrimaryEmail($login . '@smt.ufrj.br');
     $objNome = new Google_Service_Directory_UserName();
     $objNome->setFullName($arrayNome[0] . " " . $sobrenome);
     $objNome->setFamilyName($sobrenome);
     $objNome->setGivenName($arrayNome[0]);
     $postBody->setName($objNome);
     $postBody->setPassword(md5($senha));
     $postBody->setSuspended(false);
     $postBody->setHashFunction("MD5");
     $postBody->setChangePasswordAtNextLogin(true);
     //$
     $insert = $service->users->insert($postBody);
 }
 public function create_user_account($user_info)
 {
     $password = $this->createPassword();
     $client = new Google_Client();
     $client->setAssertionCredentials($this->credential);
     $service = new Google_Service_Directory($client);
     $user = new Google_Service_Directory_User();
     $name = new Google_Service_Directory_UserName();
     $name->setFamilyName($user_info['familyname']);
     $name->setGivenName($user_info['givenname']);
     $user->setPassword($password);
     $user->setPrimaryEmail($user_info['accountname'] . "@" . $this->domain);
     $user->setName($name);
     $user->setChangePasswordAtNextLogin(true);
     $res[0] = $service->users->insert($user);
     $res[1] = $password;
     return $res;
 }
Esempio n. 3
0
$cardModel = new cardModel();
$cardModel->setEtatOne($_GET['cin']);
$user_info = $cardModel->Retrive($_GET['cin']);
$id_user_1 = $user_info[0]["id_card"];
$prenom = $user_info[0]["prenom"];
$nom = $user_info[0]['nom'];
$yd_mail = $user_info[0]['yd_mail'];
$email = $user_info[0]['email'];
if ($yd_mail == 0 || strpos($email, '@youthdecides.org') === FALSE) {
    $new_nom = str_replace(" ", "", strtolower($nom));
    $new_prenom = str_replace(" ", "", strtolower($prenom));
    $password = getMeRandomPwd(8);
    $password_b_u = $password;
    //create an accout google
    // SET UP THE USER/USERNAME OBJECTS
    $user = new Google_Service_Directory_User();
    $name = new Google_Service_Directory_UserName();
    $new_person = array();
    // SET THE ATTRIBUTES
    $name->setGivenName(ucfirst($prenom));
    $name->setFamilyName(strtoupper($nom));
    $user->setName($name);
    $user->setHashFunction("SHA-1");
    $user->setPrimaryEmail("{$new_prenom}.{$new_nom}@youthdecides.org");
    $user->setPassword(hash("sha1", $password));
    // the JSON object shows us that externalIds is an array, so that's how we set it here
    echo "before insert:{$new_prenom}.{$new_nom}@youthdecides.org";
    $result = $directory->users->insert($user);
    echo "New user " . $result->primaryEmail . "||" . $password . " created successfully.";
    $email_to_add = "{$new_prenom}.{$new_nom}@youthdecides.org";
    $username = "******";
Esempio n. 4
0
if ($client->getAuth()->isAccessTokenExpired()) {
    $client->getAuth()->refreshTokenWithAssertion($cred);
}
/**
 * Create Google_Service_Directory
 */
$service = new Google_Service_Directory($client);
/**
 * Create the user
 */
$nameInstance = new Google_Service_Directory_UserName();
$nameInstance->setGivenName('John');
$nameInstance->setFamilyName('Doe');
$email = '*****@*****.**';
$password = '******';
$userInstance = new Google_Service_Directory_User();
$userInstance->setName($nameInstance);
$userInstance->setHashFunction("MD5");
$userInstance->setPrimaryEmail($email);
$userInstance->setPassword(hash("md5", $password));
try {
    $createUserResult = $service->users->insert($userInstance);
    var_dump($createUserResult);
} catch (Google_IO_Exception $gioe) {
    echo "Error in connection: " . $gioe->getMessage();
} catch (Google_Service_Exception $gse) {
    echo "User already exists: " . $gse->getMessage();
}
/**
 * If you want it, add the user to a group
 */