/**
  * Binds as $userdn with $password. This can be called with only the ldap
  * connection resource for an anonymous bind.
  *
  * @param string $userdn
  * @param string $password
  * @return bool
  * @access private
  */
 function bindAs($userdn = null, $password = null)
 {
     // Let's see if the user can authenticate.
     if ($userdn == null || $password == null) {
         $bind = LdapAuthenticationPlugin::ldap_bind($this->ldapconn);
     } else {
         $bind = LdapAuthenticationPlugin::ldap_bind($this->ldapconn, $userdn, $password);
     }
     if (!$bind) {
         $this->printDebug("Failed to bind as {$userdn}", NONSENSITIVE);
         return false;
     }
     $this->boundAs = $userdn;
     return true;
 }