Skip to content

Instantly share code, notes, and snippets.

@axfelix
Created June 25, 2010 19:43
Show Gist options
  • Save axfelix/453345 to your computer and use it in GitHub Desktop.
Save axfelix/453345 to your computer and use it in GitHub Desktop.
function authenticate($username, $password) {
$valid = false;
if ($password != null) {
if ($this->open()) {
if ($entry = $this->getUserEntry($username)) {
$userdn = ldap_get_dn($this->conn, $entry);
if ($this->bind($userdn, $password)) {
$valid = true;
}
}
$this->close();
}
return $valid;
}
}
@axfelix
Copy link
Author

axfelix commented Jun 25, 2010

As discussed in http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=5268, LDAP can bind as anonymous in the case of null credentials. I’m not entirely sure of the utility of allowing null credentials in the first place, but I imagine that this becomes irrelevant when a user chooses to enable LDAP. Suggest that the above becomes the default behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment