Wallogit.com
2017 © Pedro Peláez
This is a LDAP package meant for Northwestern University. (But can be extended for other entities), (*1)
composer require nusait/nuldap
Then update composer, (*2)
composer update
$ldap = new Nusait\Nuldap\NuLdap($rdn, $password, $host, $port);
(all parameters are optional);
if you do not put $rdn or $password, you can still validate, but cannot searchNetid. After instantiating, you can still set the rdn and password with setRdn and setPassword respectively., (*3)
$ldap->validate($netid, $password);
returns a boolean, (*4)
You can search by netid, email, emplid, or studentid., (*5)
$ldap->search('netid', $netid);
$ldap->search('email', $email);
$ldap->search('emplid', $emplid);
$ldap->search('studentid', $studentid);
This returns the raw ldap metadata., (*6)
You can also search using the magic methods:, (*7)
$ldap->searchNetid($netid); $ldap->searchEmail($email); $ldap->searchEmplid($emplid); $ldap->searchStudentid($studentid);
$ldap->parseUser($ldapUser [, $transformer ]);
You can parse the raw metadata of a user to create an associative array of the user. You can pass your own transformer into the function. The transformer must implement the TransformerInterface in the Contracts folder., (*8)
The default transforms maps the following keys and value:, (*9)
return [
'netid' => $this->getSetValueOrNull($ldapUser, 'uid'),
'phone' => $this->getSetValueOrNull($ldapUser, 'telephonenumber'),
'email' => $this->getSetValueOrNull($ldapUser, 'mail'),
'title' => $this->getSetValueOrNull($ldapUser, 'title'),
'first_name' => $this->getSetValueOrNull($ldapUser, 'givenname'),
'last_name' => $this->getSetValueOrNull($ldapUser, 'sn'),
'displayname' => $this->getSetValueOrNull($ldapUser, 'displayname'),
'emplid' => (int)$this->getSetValueOrNull($ldapUser, 'employeenumber'),
'studentid' => (int)$this->getSetValueOrNull($ldapUser, 'nustudentnumber')
];