コード例 #1
0
ファイル: CifUserTest.php プロジェクト: CIF-Rochester/Panel
 /**
  * Authenticates through Kerberos for privileged permissions.
  * This also creates our CIF user.
  */
 public static function setUpBeforeClass()
 {
     // Authenticate as a priviledged user through Kerberos
     self::$kerberos = new CifKerberos();
     self::$database = new CifMysql(DATABASE_HOSTNAME, DATABASE_ADMIN_USER, DATABASE_ADMIN_PASSWORD);
     self::$ldap = CifLdap::get_connection();
     // Create an LDAP test group
     self::$ldap->create_group(self::$test_group);
     try {
         // Create the CIF user from our desired attributes
         self::$user = CifUser::create_from(self::get_properties(), self::$password);
     } catch (Exception $e) {
         echo "\n" . self::$user->get_log();
         $this->fail($e->getMessage());
     }
 }
コード例 #2
0
ファイル: CifUser.php プロジェクト: CIF-Rochester/Panel
 /**
  * Creates a new CifUser for the given credentials.
  * If the user already exists in CIF LDAP, this method does nothing.
  * If they do not exist, their account will be initialed with data from University LDAP.
  * An AFS volume will also be created for the user's file storage if they don't already have one.
  *
  * @param string $netid The user's netID.
  * @param string $password The user's password, necessary for connecting to University LDAP.
  * @param int $lcc The user's LCC.
  * @return CifUser A CifUser object for the newly created user.
  */
 public static function create($netid, $password, $lcc)
 {
     $netid = strtolower(trim($netid));
     $lcc = intval($lcc);
     try {
         $uni_ldap = new UniversityLdap($netid, $password);
     } catch (Exception $e) {
         throw new PasswordException('Unable to connect to University servers. Bad username/password?');
     }
     $attributes = self::parse_attributes($uni_ldap->get_attributes(), 'UniversityLdap');
     // Set the user's LCC here because University LDAP doesn't give it to us
     $attributes['lcc'] = $lcc;
     return CifUser::create_from($attributes, $password);
 }