- $this->loginStatus = 'Bad username';
- return false;
- }
- $domain = $p[1];
- $dn = "mail=$user,ou=Users,domainName=$domain,$CFG->ldap_base_dn";
- $filter = "(&(objectclass=mailUser)(accountStatus=active)(mail=$user))";
- $ds = @ldap_connect($CFG->ldap_dsn);
- if ($ds) {
- @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- $r = @ldap_bind($ds, $dn, $pw);
- if ($r) {
- $sr = @ldap_search($ds, $CFG->ldap_base_dn, $filter, array('mail','domainglobaladmin'));
- $info = @ldap_get_entries($ds, $sr); // array
- if ($info['count'] > 0) {
- $_SESSION['user'] = $user;
- $this->user = $user;
- $result = true;
- $this->loginStatus = 'OK';
- $admin = 'NO';
- if (isset($info[0]['domainglobaladmin'])) {
- $admin = $info[0]['domainglobaladmin'][0];
- $admin = strtoupper($admin);
+ $this->settings['loginStatus'] = 'Bad username';
+ } else {
+ $domain = $p[1];
+ $dn = "mail=$user,ou=Users,domainName=$domain,$CFG->ldap_base_dn";
+ $filter = "(&(objectclass=mailUser)(accountStatus=active)(mail=$user))";
+ $ds = @ldap_connect($CFG->ldap_dsn);
+ if ($ds) {
+ @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+ $r = @ldap_bind($ds, $dn, $pw);
+ if ($r) {
+ $sr = @ldap_search($ds, $CFG->ldap_base_dn, $filter, array('mail','domainglobaladmin'));
+ $info = @ldap_get_entries($ds, $sr); // array
+ if ($info['count'] > 0) {
+ $this->settings['user'] = $user;
+ $result = true;
+ $this->settings['loginStatus'] = 'OK';
+ $admin = 'NO';
+ if (isset($info[0]['domainglobaladmin'])) {
+ $admin = $info[0]['domainglobaladmin'][0];
+ $admin = strtoupper($admin);
+ }
+ $this->settings['admin'] = ($admin == 'YES') ? true : false;
+ } else {
+ $this->settings['loginStatus'] = 'Login failed';