@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | return 'retry'; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if(empty($ldapSettings['port'])) { |
|
| 25 | + if (empty($ldapSettings['port'])) { |
|
| 26 | 26 | $ldapConn = ldap_connect($ldapSettings['host']); |
| 27 | 27 | } |
| 28 | 28 | else { |
| 29 | - $ldapConn = ldap_connect($ldapSettings['host'] , (int)$ldapSettings['port']); |
|
| 29 | + $ldapConn = ldap_connect($ldapSettings['host'], (int) $ldapSettings['port']); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if($ldapConn === FALSE) { |
|
| 32 | + if ($ldapConn === FALSE) { |
|
| 33 | 33 | require_once($sourcedir . '/Errors.php'); |
| 34 | 34 | $error = 'ldap connection failed'; |
| 35 | 35 | log_error($error, 'general', __FILE__, __LINE__); |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3); |
| 40 | 40 | ldap_set_option($ldapConn, LDAP_OPT_REFERRALS, 0); |
| 41 | 41 | |
| 42 | - if($ldapConn) { |
|
| 42 | + if ($ldapConn) { |
|
| 43 | 43 | $ldapbind = ldap_bind($ldapConn, $ldapSettings['rdn'], $ldapSettings['pass']); |
| 44 | 44 | |
| 45 | 45 | if ($ldapbind) { |
| 46 | - $filter = "(uid=$user)"; |
|
| 47 | - $ldapSearch = ldap_search($ldapConn, $ldapSettings['dn'], $filter); |
|
| 46 | + $filter = "(uid=$user)"; |
|
| 47 | + $ldapSearch = ldap_search($ldapConn, $ldapSettings['dn'], $filter); |
|
| 48 | 48 | |
| 49 | - if(ldap_count_entries($ldapConn, $ldapSearch) > 0 ) { |
|
| 50 | - $ldapEntry = ldap_first_entry($ldapConn,$ldapSearch); |
|
| 49 | + if (ldap_count_entries($ldapConn, $ldapSearch) > 0) { |
|
| 50 | + $ldapEntry = ldap_first_entry($ldapConn, $ldapSearch); |
|
| 51 | 51 | do // Loop through them until we find the one we want |
| 52 | 52 | { |
| 53 | - if($ldapEntry === false) break; |
|
| 54 | - $userDn = ldap_get_dn($ldapConn,$ldapEntry); |
|
| 55 | - $ldapbind = @ldap_bind($ldapConn, $userDn, $password); |
|
| 56 | - if($ldapbind) { |
|
| 57 | - $ldapattrs = ldap_get_attributes($ldapConn,$ldapEntry); |
|
| 53 | + if ($ldapEntry === false) break; |
|
| 54 | + $userDn = ldap_get_dn($ldapConn, $ldapEntry); |
|
| 55 | + $ldapbind = @ldap_bind($ldapConn, $userDn, $password); |
|
| 56 | + if ($ldapbind) { |
|
| 57 | + $ldapattrs = ldap_get_attributes($ldapConn, $ldapEntry); |
|
| 58 | 58 | |
| 59 | 59 | // verify user exists in forum user database |
| 60 | 60 | $request = $smcFunc['db_query']('', ' |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | if ($smcFunc['db_num_rows']($request) == 0) { |
| 71 | 71 | $smcFunc['db_free_result']($request); |
| 72 | 72 | |
| 73 | - if(isset($ldapattrs['givenName'][0])) { |
|
| 73 | + if (isset($ldapattrs['givenName'][0])) { |
|
| 74 | 74 | $realName = $ldapattrs['givenName'][0]; |
| 75 | 75 | } |
| 76 | 76 | else { |
| 77 | 77 | $realName = $user; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if(isset($ldapattrs['mail'][0])) { |
|
| 81 | - $emailAddress = $ldapattrs['mail'][0]; |
|
| 80 | + if (isset($ldapattrs['mail'][0])) { |
|
| 81 | + $emailAddress = $ldapattrs['mail'][0]; |
|
| 82 | 82 | } |
| 83 | 83 | else { |
| 84 | 84 | return 'please create a valid email address'; |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // User does not exist in SMF database - create it |
| 88 | 88 | require_once($sourcedir . '/Subs-Members.php'); |
| 89 | - $regOptions = array ( |
|
| 89 | + $regOptions = array( |
|
| 90 | 90 | 'username' => $user, |
| 91 | 91 | 'email' => $emailAddress, |
| 92 | - 'password' => $password , |
|
| 92 | + 'password' => $password, |
|
| 93 | 93 | 'password_check' => $password, |
| 94 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
| 94 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
| 95 | 95 | 'posts' => 0, |
| 96 | 96 | 'check_password_strength' => false, |
| 97 | 97 | 'check_email_ban' => false, |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | 'member_ip' => '', |
| 103 | 103 | 'is_activated' => 1, |
| 104 | 104 | 'validation_code' => '', |
| 105 | - 'extra_register_vars' => array ( |
|
| 105 | + 'extra_register_vars' => array( |
|
| 106 | 106 | 'real_name' => $realName, |
| 107 | 107 | ), |
| 108 | 108 | ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | return 'success'; |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | - } while ( $ldapEntry = ldap_next_entry($ldapConn,$ldapEntry) ); |
|
| 130 | + } while ($ldapEntry = ldap_next_entry($ldapConn, $ldapEntry)); |
|
| 131 | 131 | ldap_free_result($ldapSearch); |
| 132 | 132 | } |
| 133 | 133 | } |