You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(7) |
Jul
(5) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
(5) |
Mar
(9) |
Apr
(5) |
May
(3) |
Jun
(2) |
Jul
(9) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(1) |
Dec
|
2010 |
Jan
(5) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(3) |
Jun
(5) |
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <axe...@us...> - 2009-03-15 19:50:39
|
Revision: 71 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=71&view=rev Author: axelseaa Date: 2009-03-15 19:50:30 +0000 (Sun, 15 Mar 2009) Log Message: ----------- added the ability to email new users when they are added to blog, and allows for message customization. Also corrected issue with default settings on an initial install. Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_adduser.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 05:58:20 UTC (rev 70) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-15 19:50:30 UTC (rev 71) @@ -186,7 +186,7 @@ if ($createUser) { if ($user_id = username_exists($username)) { if (wpmuLdapAddUserToBlog($user_id,$blog_id,$new_role)) { - return array( true ); + return array( true, $user_id ); } } if (wpmuLdapCreateWPUserFromLdap($username,'',$userDataArray)) { Modified: trunk/ldap/lib/wpmu_ldap_adduser.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2009-03-08 05:58:20 UTC (rev 70) +++ trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2009-03-15 19:50:30 UTC (rev 71) @@ -78,6 +78,7 @@ $result = wpmuLdapSearchUser($username,$blog_id,$user['new_role']); $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); if ($result[0]) { + wp_new_user_notification($result[1]); ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); } elseif ($ldapCreateLocalUser || is_site_admin($current_user->username)) { ?> @@ -97,9 +98,10 @@ } } else { // Add User to Blog - if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['new_role'])) + if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['new_role'])) { + wp_new_user_notification($login->ID); ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); - else + } else ldapAddUserResult(array('updated' => 'false','action' => 'exists','username' => $username)); } } elseif ($_POST['addUserBulk']) { @@ -121,15 +123,17 @@ if (!$login) { $result = wpmuLdapSearchUser($username,$blog_id,$user['bulk_new_role']); if ($result[0]) { + wp_new_user_notification($result[1]); ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); } else { ldapAddUserResult(array('updated' => 'false','action' => 'notfound','username' => $username)); } } else { // Add User to Blog - if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['bulk_new_role'])) + if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['bulk_new_role'])) { + wp_new_user_notification($login->ID); ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); - else + } else ldapAddUserResult(array('updated' => 'false','action' => 'exists','username' => $username)); } } Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-08 05:58:20 UTC (rev 70) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-15 19:50:30 UTC (rev 71) @@ -78,6 +78,41 @@ } function getWpmuLdapSiteOptions() { + $defaultSignupMessage = 'Public sign-up has been disabled.'; + + $sysAdminEmail = get_site_option('admin_email'); + $defaultGetPasswordMessage = <<<GetPasswordMsg +Your account is tied to an account in the central directory. You cannot +retrieve your password via email. Please contact the +<a href="mailto:$sysAdminEmail">system administrator</a> for information on how +to reset your password. +GetPasswordMsg; + + $defaultLDAPEmailSubj = $defaultLocalEmailSubj = 'Blogging Account Created'; + $defaultLDAPEmailMessage = 'Dear User, + +You have just been permitted to access a new blog! + +Username: USERNAME +Login: LOGINLINK + +We hope you enjoy your new weblog. + Thanks! + +--Wordpress'; + $defaultLocalEmailMessage = 'Dear User, + +You have just been permitted to access a new blog! + +Username: USERNAME +Password: PASSWORD +Login: LOGINLINK + +We hope you enjoy your new weblog. + Thanks! + +--Wordpress'; + $ret = array(); $ret['ldapAuth'] = get_site_option('ldapAuth'); $ret['ldapCreateAcct'] = get_site_option('ldapCreateAcct'); @@ -90,6 +125,12 @@ $ret['ldapEnableSSL'] = get_site_option('ldapEnableSSL'); $ret['ldapServerPass'] = get_site_option('ldapServerPass'); $ret['ldapDisableSignup'] = get_site_option('ldapDisableSignup'); + $ret['ldapLocalEmail'] = get_site_option('ldapLocalEmail'); + $ret['ldapLocalEmailSubj'] = get_site_option('ldapLocalEmailSubj',$defaultLocalEmailSubj); + $ret['ldapLocalEmailMessage'] = stripslashes(get_site_option('ldapLocalEmailMessage', $defaultLocalEmailMessage)); + $ret['ldapLDAPEmail'] = get_site_option('ldapLDAPEmail'); + $ret['ldapLDAPEmailSubj'] = get_site_option('ldapLDAPEmailSubj',$defaultLDAPEmailSubj); + $ret['ldapLDAPEmailMessage'] = stripslashes(get_site_option('ldapLDAPEmailMessage', $defaultLDAPEmailMessage)); $ret['ldapCreateLocalUser'] = get_site_option('ldapCreateLocalUser'); $ret['ldapSignupMessage'] = stripslashes(get_site_option('ldapSignupMessage', $defaultSignupMessage)); $ret['ldapGetPasswordMessage'] = stripslashes(get_site_option('ldapGetPasswordMessage', $defaultGetPasswordMessage)); @@ -99,16 +140,6 @@ } function ldapOptionsPanelGeneral() { - $defaultSignupMessage = 'Public sign-up has been disabled.'; - - $sysAdminEmail = get_site_option('admin_email'); - $defaultGetPasswordMessage = <<<GetPasswordMsg -Your account is tied to an account in the central directory. You cannot -retrieve your password via email. Please contact the -<a href="mailto:$sysAdminEmail">system administrator</a> for information on how -to reset your password. -GetPasswordMsg; - extract(getWpmuLdapSiteOptions()); // default values to avoid PHP notices about unset values @@ -129,6 +160,12 @@ if($ldapDisableSignup) $tDisableSignup = "checked='checked'"; else $fDisableSignup = "checked='checked'"; + if($ldapLocalEmail) $tLocalEmail = "checked='checked'"; + else $fLocalEmail = "checked='checked'"; + + if($ldapLDAPEmail) $tLDAPEmail = "checked='checked'"; + else $fLDAPEmail = "checked='checked'"; + if($ldapCreateLocalUser) $tCreateLocalUser = "checked='checked'"; else $fCreateLocalUser = "checked='checked'"; @@ -208,6 +245,34 @@ This is the error message that would be displayed when an LDAP-account user submits "Lost Password" requests. </td> </tr> + <tr valign="top"> + <th scope="row">New user email notification (Local Users):</th> + <td> + <input type='radio' name='ldapLocalEmail' id='disableLocalEmailYes' value='1' <?php echo $tLocalEmail; ?>/> <label for="disableLocalEmailYes">Yes</label> + <input type='radio' name='ldapLocalEmail' id='disableLocalEmailNo' value='0' <?php echo $fLocalEmail; ?>/> <label for="disableLocalEmailNo">No</label> + <br/> + Controls whether or not local users are emailed on account creation or when receiving access to a new blog. + <br/><br/> + <label for="ldapLocalEmailSubj">Email Subject:</label><br/> + <input type="text" name="ldapLocalEmailSubj" id="ldapLocalEmailSubj" value="<?php echo $ldapLocalEmailSubj ?>" /><br /> + <label for="ldapLocalEmailMessage">Email Body:</label><br/> + <textarea name="ldapLocalEmailMessage" id="ldapLocalEmailMessage" rows="5" cols="45" style="width: 95%;"><?php echo $ldapLocalEmailMessage ?></textarea> + </td> + </tr> + <tr valign="top"> + <th scope="row">New user email notification (LDAP Users):</th> + <td> + <input type='radio' name='ldapLDAPEmail' id='disableLDAPEmailYes' value='1' <?php echo $tLDAPEmail; ?>/> <label for="disableLDAPEmailYes">Yes</label> + <input type='radio' name='ldapLDAPEmail' id='disableLDAPEmailNo' value='0' <?php echo $fLDAPEmail; ?>/> <label for="disableLDAPEmailNo">No</label> + <br/> + Controls whether or not ldap users are emailed on account creation or when receiving access to a new blog. + <br/><br/> + <label for="ldapLDAPEmailSubj">Email Subject:</label><br/> + <input type="text" name="ldapLDAPEmailSubj" id="ldapLDAPEmailSubj" value="<?php echo $ldapLDAPEmailSubj ?>" /><br /> + <label for="ldapLDAPEmailMessage">Email Body:</label><br/> + <textarea name="ldapLDAPEmailMessage" id="ldapLDAPEmailMessage" rows="5" cols="45" style="width: 95%;"><?php echo $ldapLDAPEmailMessage ?></textarea> + </td> + </tr> </table> <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save Options" /></p> </form> @@ -274,7 +339,7 @@ </td> </tr> <tr valign="top"> - <th scope="row"><label for="serverPort">LDAP Server Port:</label></th> + <th scope="row"><label for="serverPort">Server Port:</label></th> <td> <input type='text' name='ldapServerPort' id='serverPort' value='<?php echo $ldapServerPort ?>' style='width: 300px;' /> <br/> @@ -421,30 +486,49 @@ * */ function wp_new_user_notification($user_id, $plaintext_pass = '') { + global $current_site; $user = new WP_User($user_id); $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); $ldap_login = get_usermeta($user_id, 'ldap_login'); - $message = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n"; - $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; - $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; + if (empty($plaintext_pass)) $plaintext_pass = "Your SITE_NAME Password"; - @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message); + $msg = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n"; + $msg .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; + $msg .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; - if ($ldap_login == true) { - $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; - $message .= get_option('siteurl') . "/wp-login.php\r\n"; - } else { - if ( empty($plaintext_pass) ) - return; - $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; - $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; - $message .= get_option('siteurl') . "/wp-login.php\r\n"; + $subj = 'Blogging Account Created'; + + if ($ldap_login == true) { // LDAP Users + if (get_site_option('ldapLDAPEmail')) { // Check to see if LDAP email notifications are enabled + $msg .= sprintf(__('Username: %s'), $user_login) . "\r\n"; + $msg .= get_option('siteurl') . "LOGINLINK\r\n"; + $ldapmsg = get_site_option('ldapLDAPEmailMessage'); + if (!empty($ldapmsg)) $msg = $ldapmsg; + $ldapsubj = get_site_option('ldapLDAPEmailSubj'); + if (!empty($ldapsubj)) $subj = $ldapsubj; + } else return; + } else { // Local Users + if (get_site_option('ldapLocalEmail')) { // Check to see if local email notifications are enabled + $msg .= sprintf(__('Username: %s'), $user_login) . "\r\n"; + $msg .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; + $msg .= get_option('siteurl') . "/wp-login.php\r\n"; + $localmsg = get_site_option('ldapLocalEmailMessage'); + if (!empty($localmsg)) $msg = $localmsg; + $localsubj = get_site_option('ldapLocalEmailSubj'); + if (!empty($localsubj)) $subj = $localsubj; + } else return; } - wp_mail($user_email, sprintf(__('[%s] Blogging Account Created'), get_option('blogname')), $message); + $msg = str_replace( "PASSWORD", $plaintext_pass, $msg ); + $msg = str_replace( "SITE_NAME", $current_site->site_name, $msg ); + $msg = str_replace( "USERNAME", $user_login, $msg ); + $msg = str_replace( "USEREMAIL", $user_email, $msg ); + $msg = str_replace( "LOGINLINK", site_url( 'wp-login.php' ), $msg ); + + wp_mail($user_email, sprintf(__('[%s] %s'), get_option('blogname'), $subj), $msg); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-08 05:58:38
|
Revision: 70 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=70&view=rev Author: axelseaa Date: 2009-03-08 05:58:20 +0000 (Sun, 08 Mar 2009) Log Message: ----------- added tls support - testers needed! Modified Paths: -------------- trunk/ldap/lib/ldap_core.php trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/ldap_core.php =================================================================== --- trunk/ldap/lib/ldap_core.php 2009-03-08 04:45:33 UTC (rev 69) +++ trunk/ldap/lib/ldap_core.php 2009-03-08 05:58:20 UTC (rev 70) @@ -56,6 +56,13 @@ else { $return = true; ldap_set_option($this->connection_handle, LDAP_OPT_PROTOCOL_VERSION, 3); + // Start TLS + if ($this->usessl == 2) { + if (!ldap_start_tls($this->connection_handle)) { + $return = false; + $this->LogError(); + } + } if (!get_site_option('ldapLinuxWindows')) { //Windows Only ldap_set_option($this->connection_handle, LDAP_OPT_REFERRALS, 0); Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 04:45:33 UTC (rev 69) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 05:58:20 UTC (rev 70) @@ -255,5 +255,7 @@ function wpmuLdapTestConnection() { $server = new LDAP_ro(wpmuSetupLdapOptions()); $server->DebugOff(); - return $server->testConnect(); + $result = $server->testConnect(); + $server->Disconnect(); + return $result; } Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-08 04:45:33 UTC (rev 69) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-08 05:58:20 UTC (rev 70) @@ -225,7 +225,8 @@ if($ldapAuth) $tChecked = "checked='checked'"; else $fChecked = "checked='checked'"; - if($ldapEnableSSL) $tEnableSSL = "checked='checked'"; + if($ldapEnableSSL == 1) $tEnableSSL = "checked='checked'"; + elseif ($ldapEnableSSL == 2) $tEnableTLS = "checked='checked'"; else $fEnableSSL = "checked='checked'"; if($ldapLinuxWindows) $tLinWin = "checked='checked'"; @@ -255,12 +256,13 @@ </td> </tr> <tr valign="top"> - <th scope="row">Enable SSL:</th> + <th scope="row">Server Encryption:</th> <td> - <input type='radio' name='ldapEnableSSL' id='sslOn' value='1' <?php echo $tEnableSSL ?>/> <label for="sslOn">Yes</label> - <input type='radio' name='ldapEnableSSL' id='sslOff' value='0' <?php echo $fEnableSSL ?>/> <label for="sslOff">No</label> + <input type='radio' name='ldapEnableSSL' id='sslOff' value='0' <?php echo $fEnableSSL ?>/> <label for="sslOff">None</label> + <input type='radio' name='ldapEnableSSL' id='sslOn' value='1' <?php echo $tEnableSSL ?>/> <label for="sslOn">SSL</label> + <input type='radio' name='ldapEnableSSL' id='sslTLS' value='2' <?php echo $tEnableTLS ?>/> <label for="sslTLS">TLS</label> <br/> - Select yes to connect over ldaps://, Select no to connect over ldap:// + Select none to connect over ldap://, Select SSL to connect over ldaps://, Select TLS to connect using TLS encryption </td> </tr> <tr valign="top"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-08 04:45:55
|
Revision: 69 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=69&view=rev Author: axelseaa Date: 2009-03-08 04:45:33 +0000 (Sun, 08 Mar 2009) Log Message: ----------- minor corrections Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 04:36:57 UTC (rev 68) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 04:45:33 UTC (rev 69) @@ -15,7 +15,7 @@ // Check to see if email already exists if ( email_exists($ldapUserData[LDAP_INDEX_EMAIL]) ) - return new WP_Error('ldapcreate_failed', __('<strong>ERROR</strong>: <strong>'.$ldapUserData[LDAP_INDEX_EMAIL].'</strong> is already associated with another account. All accounts (include the admin account) must have an unique email address.')); + return new WP_Error('ldapcreate_emailconflict', sprintf(__('<strong>ERROR</strong>: <strong>%s</strong> is already associated with another account. All accounts (including the admin account) must have an unique email address.'),$ldapUserData[LDAP_INDEX_EMAIL])); // we don't actually care about the WP password (since it's LDAP), but we // need one for WP database This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-08 04:37:15
|
Revision: 68 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=68&view=rev Author: axelseaa Date: 2009-03-08 04:36:57 +0000 (Sun, 08 Mar 2009) Log Message: ----------- adjusted to display specific error if an email address conflict occurs Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-07 22:27:31 UTC (rev 67) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-08 04:36:57 UTC (rev 68) @@ -13,6 +13,10 @@ function wpmuLdapCreateWPUserFromLdap($newUserName, $newUserPassword, $ldapUserData) { global $base, $error, $wpdb, $current_site; + // Check to see if email already exists + if ( email_exists($ldapUserData[LDAP_INDEX_EMAIL]) ) + return new WP_Error('ldapcreate_failed', __('<strong>ERROR</strong>: <strong>'.$ldapUserData[LDAP_INDEX_EMAIL].'</strong> is already associated with another account. All accounts (include the admin account) must have an unique email address.')); + // we don't actually care about the WP password (since it's LDAP), but we // need one for WP database $sPassword = generate_random_password(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-07 22:27:36
|
Revision: 67 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=67&view=rev Author: axelseaa Date: 2009-03-07 22:27:31 +0000 (Sat, 07 Mar 2009) Log Message: ----------- revamped options screen - added option to test ldap connection on form submit - also remove old styles from css Modified Paths: -------------- trunk/ldap/lib/ldap_ro.php trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap/public/ldap_auth.css Modified: trunk/ldap/lib/ldap_ro.php =================================================================== --- trunk/ldap/lib/ldap_ro.php 2009-03-04 03:38:06 UTC (rev 66) +++ trunk/ldap/lib/ldap_ro.php 2009-03-07 22:27:31 UTC (rev 67) @@ -172,5 +172,14 @@ function GetDNParts ($in_dn) { return ldap_explode_dn ($in_dn, 0); } + + // Test connection + function testConnect () { + return $this->Dock(); + if (!$this->Dock()) + return false; + else + return true; + } } ?> Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-04 03:38:06 UTC (rev 66) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-03-07 22:27:31 UTC (rev 67) @@ -247,3 +247,9 @@ $error = '<strong>ERROR:</strong> '.stripslashes(get_site_option('ldapSignupMessage')); } } + +function wpmuLdapTestConnection() { + $server = new LDAP_ro(wpmuSetupLdapOptions()); + $server->DebugOff(); + return $server->testConnect(); +} Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-04 03:38:06 UTC (rev 66) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-07 22:27:31 UTC (rev 67) @@ -19,84 +19,86 @@ * @return null - does not actively return a value * @see ldap_addmenu */ -function newldapOptionsPanel() { +function ldapOptionsPanel() { global $current_blog; + + // Process POST Updates + if ($_SERVER['REQUEST_METHOD'] == 'POST') wpmuProcessUpdates(); + $tab = $_GET['ldaptab']; - $allowedtabs = array('general','attributes','updates'); + $allowedtabs = array('general','connection','attributes','updates'); ?> <div class="wrap"> - <h2><?php _e('Ldap Authentication Options'); ?></h2> - <hr/> - <p>General Settings | Attribute Mapping | Upgrade</p> - <hr/> - <?php + wpmuLdapOptionsMenu($tab); if ($tab == 'attributes') { } elseif ($tab == 'upgrade') { ldapOptionsPanelUpdates(); + } elseif ($tab == 'general') { + ldapOptionsPanelGeneral(); } else { - + ldapOptionsPanelConnection(); } ?> </div> <?php } -function ldapOptionsPanelGeneral() { - +function wpmuLdapOptionsMenu($tab) { + echo '<h2>'._('Ldap Authentication Options').'</h2>'; + echo '<p>'; + echo '<a href="?page=wpmu_ldap_admin.functions.php"'.((empty($tab) || $tab == 'connection') ? ' class="wpmuLdapOptionMenuSelected"' : '').'>Connection Settings</a> | '; + echo '<a href="?page=wpmu_ldap_admin.functions.php&ldaptab=general"'.($tab == 'general' ? ' class="wpmuLdapOptionMenuSelected"' : '').'>General Settings</a> | '; + #echo '<a href="?page=wpmu_ldap_admin.functions.php&ldaptab=attributes"'.($tab == 'attributes' ? ' class="wpmuLdapOptionMenuSelected"' : '').'>Attribute Mapping</a> | '; + echo '<a href="?page=wpmu_ldap_admin.functions.php&ldaptab=upgrade"'.($tab == 'upgrade' ? ' class="wpmuLdapOptionMenuSelected"' : '').'>Upgrade</a>'; + echo '</p><hr/>'; } -function ldapOptionsPanelUpdates() { -?> - <form method="post" id="ldap_fix_meta"> - <h3>Upgrade</h3> - <table class="form-table"> - <tr valign="top"> - <th scope="row"><?php _e('Update Meta'); ?></th> - <td> - WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. - </td> - </tr> - </table> - <p class="submit"> - <?php echo $ldapfixmeta ?> - <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> - </p> - </form> -<?php -} +function wpmuProcessUpdates() { + if($_POST['ldapOptionsSave']) { + foreach ($_POST as $key => $item) + if ($key != 'ldapOptionsSave' || $key != 'ldapTestConnection') update_site_option($key,stripslashes($item)); -function ldapOptionsPanelAttributes() { + # Test Ldap Connection + if ($_POST['ldapTestConnection']) { + if (wpmuLdapTestConnection()) + echo "<div id='message' class='updated fade'><p><b>LDAP Connection Test:</b> Successful!</p></div>"; + else + echo "<div id='message' class='error fade'><p><b>LDAP Connection Test:</b> Failed</p></div>"; + } + echo "<div id='message' class='updated fade'><p>Saved Options!</p></div>"; + } else if ($_POST['ldapFixMeta']) { + wpmuLdapFixMeta(); + update_site_option('ldapfixmetafor15','true'); + echo "<div id='message' class='updated fade'><p>All users ldap_auth meta values updated!</p></div>"; + } + } -function ldapOptionsPanel() { - global $current_blog; - if($_POST['ldapOptionsSave']) { - update_site_option('ldapAuth', $_POST['ldapOptionsAuth']); - update_site_option('ldapCreateAcct', $_POST['ldapOptionsCreateAcct']); - update_site_option('ldapCreateBlog', $_POST['ldapOptionsCreateBlog']); - update_site_option('ldapLinuxWindows', $_POST['ldapOptionsLinuxWindows']); - update_site_option('ldapServerAddr', $_POST['ldapOptionsServerAddr']); - update_site_option('ldapServerPort', $_POST['ldapOptionsServerPort']); - update_site_option('ldapServerOU', $_POST['ldapOptionsServerOU']); - update_site_option('ldapServerCN', $_POST['ldapOptionsServerCN']); - update_site_option('ldapServerPass', $_POST['ldapOptionsServerPass']); - update_site_option('ldapEnableSSL', $_POST['ldapOptionsEnableSSL']); - update_site_option('ldapBulkAdd', $_POST['ldapOptionsBulkAdd']); - update_site_option('ldapDisableSignup', $_POST['ldapOptionsDisableSignup']); - update_site_option('ldapCreateLocalUser', $_POST['ldapOptionsCreateLocalUser']); - update_site_option('ldapSignupMessage', stripslashes($_POST['ldapSignupMessage'])); - update_site_option('ldapGetPasswordMessage', stripslashes($_POST['ldapGetPasswordMessage'])); +function getWpmuLdapSiteOptions() { + $ret = array(); + $ret['ldapAuth'] = get_site_option('ldapAuth'); + $ret['ldapCreateAcct'] = get_site_option('ldapCreateAcct'); + $ret['ldapCreateBlog'] = get_site_option('ldapCreateBlog'); + $ret['ldapLinuxWindows'] = get_site_option('ldapLinuxWindows'); + $ret['ldapServerAddr'] = get_site_option('ldapServerAddr'); + $ret['ldapServerPort'] = get_site_option('ldapServerPort'); + $ret['ldapServerOU'] = get_site_option('ldapServerOU'); + $ret['ldapServerCN'] = get_site_option('ldapServerCN'); + $ret['ldapEnableSSL'] = get_site_option('ldapEnableSSL'); + $ret['ldapServerPass'] = get_site_option('ldapServerPass'); + $ret['ldapDisableSignup'] = get_site_option('ldapDisableSignup'); + $ret['ldapCreateLocalUser'] = get_site_option('ldapCreateLocalUser'); + $ret['ldapSignupMessage'] = stripslashes(get_site_option('ldapSignupMessage', $defaultSignupMessage)); + $ret['ldapGetPasswordMessage'] = stripslashes(get_site_option('ldapGetPasswordMessage', $defaultGetPasswordMessage)); + $ret['ldapfixmetafor15'] = get_site_option('ldapfixmetafor15'); + $ret['ldapBulkAdd'] = get_site_option('ldapBulkAdd'); + return $ret; +} - echo "<div id='message' class='updated fade'><p>Saved Options!</p></div>"; - } else if ($_POST['ldapFixMeta']) { - wpmuLdapFixMeta(); - update_site_option('ldapfixmetafor15','true'); - echo "<div id='message' class='updated fade'><p>All users ldap_auth meta values updated!</p></div>"; - } - +function ldapOptionsPanelGeneral() { $defaultSignupMessage = 'Public sign-up has been disabled.'; $sysAdminEmail = get_site_option('admin_email'); @@ -107,263 +109,246 @@ to reset your password. GetPasswordMsg; - $ldapAuth = get_site_option('ldapAuth'); - $ldapCreateAcct = get_site_option('ldapCreateAcct'); - $ldapCreateBlog = get_site_option('ldapCreateBlog'); - $ldapLinuxWindows = get_site_option('ldapLinuxWindows'); - $ldapCookieMarker = get_site_option('ldapCookieMarker'); - $ldapServerAddr = get_site_option('ldapServerAddr'); - $ldapServerPort = get_site_option('ldapServerPort'); - $ldapServerOU = get_site_option('ldapServerOU'); - $ldapServerCN = get_site_option('ldapServerCN'); - $ldapEnableSSL = get_site_option('ldapEnableSSL'); - $ldapServerPass = get_site_option('ldapServerPass'); - $ldapDisableSignup = get_site_option('ldapDisableSignup'); - $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); - $ldapSignupMessage = stripslashes(get_site_option('ldapSignupMessage', $defaultSignupMessage)); - $ldapGetPasswordMessage = stripslashes(get_site_option('ldapGetPasswordMessage', $defaultGetPasswordMessage)); - $ldapfixmetafor15 = get_site_option('ldapfixmetafor15'); - $ldapBulkAdd = get_site_option('ldapBulkAdd'); + extract(getWpmuLdapSiteOptions()); // default values to avoid PHP notices about unset values - $tChecked = ''; - $fChecked = ''; - $tAcctChecked = ''; - $fAcctChecked = ''; - $tBlogChecked = ''; - $fBlogChecked = ''; - $tLinWin = ''; - $fLinWin = ''; - $tEnableSSL = ''; - $fEnableSSL = ''; - $tDisableSignup = ''; - $fDisableSignup = ''; - $tCreateLocalUser = ''; - $fCreateLocalUser = ''; + $tAcctChecked = ''; $fAcctChecked = ''; + $tBlogChecked = ''; $fBlogChecked = ''; + $tDisableSignup = ''; $fDisableSignup = ''; + $tCreateLocalUser = ''; $fCreateLocalUser = ''; - if($ldapAuth) { - $tChecked = "checked='checked'"; - } - else { - $fChecked = "checked='checked'"; - } + if($ldapCreateAcct) $tAcctChecked = "checked='checked'"; + else $fAcctChecked = "checked='checked'"; - if($ldapCreateAcct) { - $tAcctChecked = "checked='checked'"; - } - else { - $fAcctChecked = "checked='checked'"; - } + if($ldapCreateBlog) $tBlogChecked = "checked='checked'"; + else $fBlogChecked = "checked='checked'"; - if($ldapCreateBlog) { - $tBlogChecked = "checked='checked'"; - } - else { - $fBlogChecked = "checked='checked'"; - } + if($ldapBulkAdd) $tBulkAdd = "checked='checked'"; + else $fBulkAdd = "checked='checked'"; - if($ldapLinuxWindows) { - $tLinWin = "checked='checked'"; - } - else { - $fLinWin = "checked='checked'"; - } + if($ldapDisableSignup) $tDisableSignup = "checked='checked'"; + else $fDisableSignup = "checked='checked'"; - if($ldapBulkAdd) { - $tBulkAdd = "checked='checked'"; - } - else { - $fBulkAdd = "checked='checked'"; - } + if($ldapCreateLocalUser) $tCreateLocalUser = "checked='checked'"; + else $fCreateLocalUser = "checked='checked'"; - if($ldapEnableSSL) { - $tEnableSSL = "checked='checked'"; - } - else { - $fEnableSSL = "checked='checked'"; - } - - if($ldapDisableSignup) { - $tDisableSignup = "checked='checked'"; - } - else { - $fDisableSignup = "checked='checked'"; - } - - if($ldapCreateLocalUser) { - $tCreateLocalUser = "checked='checked'"; - } - else { - $fCreateLocalUser = "checked='checked'"; - } - - if(!empty($ldapfixmetafor15)) { - $ldapfixmeta = "<span class='ldapmeta'>This has already been run, are you sure you want to fix meta again?</span><br/><br/>"; - } else { - $ldapfixmeta = ''; - } - - if (!is_numeric($ldapServerPort)) { - $ldapServerPort = 389; - } - - $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; - $moreInfoImgUrl = $schema.$current_blog->domain.$current_blog->path."wp-content/mu-plugins/ldap/public/more-info.gif"; - ?> -<div class="wrap"> - <h2><?php _e('Ldap Authentication Options'); ?></h2> - <p>General Settings | Attribute Mapping | Upgrade</p> - <p> - To start allowing users to log in with LDAP credentials, you will need to - Enable LDAP-Authentication below. LDAP Authentication is available for all - accounts. It is recommended that you still maintain a local <strong>admin</strong> - account to allow access if the LDAP server is unavailable. - </p> <form method="post" id="ldap_auth_options"> - <h3>LDAP Settings</h3> + <h3>General Settings</h3> <table class="form-table"> <tr valign="top"> - <th scope="row">LDAP-Authentication</th> + <th scope="row">Auto-Create WPMU Accounts?</th> <td> - <input type='radio' name='ldapOptionsAuth' id='authEnable' value='1' <?php echo $tChecked ?>/> <label for="authEnable">Enabled</label> - <input type='radio' name='ldapOptionsAuth' id='authDisable' value='0' <?php echo $fChecked ?>/> <label for="authDisable">Disabled</label> + <input type='radio' name='ldapCreateAcct' id='createAcctYes' value='1' <?php echo $tAcctChecked ?>/> <label for="createAcctYes">Yes</label> + <input type='radio' name='ldapCreateAcct' id='createAcctNo' value='0' <?php echo $fAcctChecked ?>/> <label for="createAcctNo">No</label> <br/> - If this is disabled, then entire plugin will be disabled. Users will need to log in using WPMU user credentials, and will not be able to use LDAP credentials to access their accounts. + If "Yes", this will automatically create a WPMU account for any user + that successfully authenticates against the LDAP server. The WPMU user + account will be named the same as the LDAP username. + <br/><br/> + If "No", then a + Site Admin must create a WPMU user account for the user to be able to + log in. The WPMU user account must be named the same as the LDAP + username for LDAP authentication to function. </td> </tr> <tr valign="top"> - <th scope="row">Enable SSL</th> + <th scope="row">Auto-Create WPMU Blogs?</th> <td> - <input type='radio' name='ldapOptionsEnableSSL' id='sslOn' value='1' <?php echo $tEnableSSL ?>/> <label for="sslOn">Yes</label> - <input type='radio' name='ldapOptionsEnableSSL' id='sslOff' value='0' <?php echo $fEnableSSL ?>/> <label for="sslOff">No</label> + <input type='radio' name='ldapCreateBlog' id='createBlogYes' value='1' <?php echo $tBlogChecked; ?>/> <label for="createBlogYes">Yes</label> + <input type='radio' name='ldapCreateBlog' id='createBlogNo' value='0' <?php echo $fBlogChecked; ?>/> <label for="createBlogNo">No</label> <br/> - Select yes to connect over ldaps://, Select no to connect over ldap:// + If "Yes", this will automatically create a WPMU blog for any user that successfully authenticates against the LDAP server. The blog will be named the same as the LDAP username. + <br/><br/> + If "No", then a Site Admin must create a WPMU blog for the user to be able to log in. </td> </tr> <tr valign="top"> - <th scope="row"><label for="serverAddr">Server Address</label></th> + <th scope="row">Create local users?</th> <td> - <input type='text' name='ldapOptionsServerAddr' id='serverAddr' value='<?php echo $ldapServerAddr ?>' style='width: 300px;' /> + <input type='radio' name='ldapCreateLocalUser' id='createLocalUserYes' value='1' <?php echo $tCreateLocalUser ?>/> <label for="createLocalUserYes">Yes</label> + <input type='radio' name='ldapCreateLocalUser' id='createLocalUserNo' value='0' <?php echo $fCreateLocalUser ?>/> <label for="createLocalUserNo">No</label> <br/> - The name or IP address of the LDAP server. The protocol should be left out. (Ex. ldap.example.com) + This will either allow or disallow the creation of local accounts. </td> </tr> <tr valign="top"> - <th scope="row"><label for="serverPort">LDAP Server Port</label></th> + <th scope="row">Allow blog admins to bulk add?</th> <td> - <input type='text' name='ldapOptionsServerPort' id='serverPort' value='<?php echo $ldapServerPort ?>' style='width: 300px;' /> + <input type='radio' name='ldapBulkAdd' id='bulkaddyes' value='1' <?php echo $tBulkAdd; ?>/> <label for="bulkaddyes">Yes</label> + <input type='radio' name='ldapBulkAdd' id='bulkaddno' value='0' <?php echo $fBulkAdd; ?>/> <label for="bulkaddno">No</label> <br/> - Port Number of the LDAP server. (LDAP: Linux=389, Windows=3268) (LDAPS: Linux=686, Windows=3269) + This option specifies whether or not the individual blog admins are able to bulk add users. Site admins are + always able to bulk add regardless of this setting. </td> </tr> <tr valign="top"> - <th scope="row"><label for="serverOU">Search DN</label></th> + <th scope="row">Disable Public Signup?</th> <td> - <input type='text' name='ldapOptionsServerOU' id='serverOU' value='<?php echo $ldapServerOU; ?>' style='width: 450px;' /> + <input type='radio' name='ldapDisableSignup' id='disableSignupYes' value='1' <?php echo $tDisableSignup; ?>/> <label for="disableSignupYes">Yes</label> + <input type='radio' name='ldapDisableSignup' id='disableSignupNo' value='0' <?php echo $fDisableSignup; ?>/> <label for="disableSignupNo">No</label> <br/> - The base DN in which to carry out LDAP searches. + This overrides all actions that take place within wp-signup.php, effectively disabling public signup. </td> </tr> <tr valign="top"> - <th scope="row"><label for="serverCN">User DN for Searches</label></th> + <th scope="row"><label for="ldapSignupMessage">Signup-Disabled Message:</label></th> <td> - <input type='text' name='ldapOptionsServerCN' id='serverCN' value='<?php echo $ldapServerCN; ?>' style='width: 450px;' /> - <br/> - Some systems do not allow anonymous searching for attributes, and so this will set the account to use when connecting for searches. + <textarea name='ldapSignupMessage' id='ldapSignupMessage' rows="5" cols="45" style="width: 95%;"><?php echo $ldapSignupMessage ?></textarea> + <br/> + This is an alternate HTML message that would be displayed in place of any actions at wp-signup.php. </td> </tr> <tr valign="top"> - <th scope="row"><label for='serverPass'>Password</label></th> + <th scope="row"><label for="ldapGetPasswordMessage">Lost-Password Message:</label></th> <td> - <input type='password' name='ldapOptionsServerPass' id='serverPass' value='<?php echo $ldapServerPass; ?>' /> + <textarea name='ldapGetPasswordMessage' id='ldapGetPasswordMessage' rows="5" cols="45" style="width: 95%;"><?php echo $ldapGetPasswordMessage ?></textarea> <br/> - Password for the User DN above. + This is the error message that would be displayed when an LDAP-account user submits "Lost Password" requests. </td> </tr> + </table> + <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save Options" /></p> + </form> +<?php +} + +function ldapOptionsPanelConnection() { + extract(getWpmuLdapSiteOptions()); + + // default values to avoid PHP notices about unset values + $tChecked = ''; $fChecked = ''; + $tLinWin = ''; $fLinWin = ''; + $tEnableSSL = ''; $fEnableSSL = ''; + + if($ldapAuth) $tChecked = "checked='checked'"; + else $fChecked = "checked='checked'"; + + if($ldapEnableSSL) $tEnableSSL = "checked='checked'"; + else $fEnableSSL = "checked='checked'"; + + if($ldapLinuxWindows) $tLinWin = "checked='checked'"; + else $fLinWin = "checked='checked'"; + + if (!is_numeric($ldapServerPort)) + $ldapServerPort = 389; + +?> + <p> + To start allowing users to log in with LDAP credentials, you will need to + Enable LDAP-Authentication below. LDAP Authentication is available for all + accounts. It is recommended that you still maintain a local <strong>admin</strong> + account to allow access if the LDAP server is unavailable. + </p> + + <form method="post" id="ldap_auth_options"> + <h3>Connection Settings</h3> + <table class="form-table"> <tr valign="top"> - <th scope="row">LDAP Type</th> + <th scope="row">LDAP-Authentication:</th> <td> - <input type='radio' name='ldapOptionsLinuxWindows' id='linux' value='1' <?php echo $tLinWin; ?>/> <label for="linux">Linux</label> - <input type='radio' name='ldapOptionsLinuxWindows' id='windows' value='0' <?php echo $fLinWin; ?>/> <label for="windows">Windows</label> + <input type='radio' name='ldapAuth' id='authEnable' value='1' <?php echo $tChecked ?>/> <label for="authEnable">Enabled</label> + <input type='radio' name='ldapAuth' id='authDisable' value='0' <?php echo $fChecked ?>/> <label for="authDisable">Disabled</label> + <br/> + If this is disabled, then entire plugin will be disabled. Users will need to log in using WPMU user credentials, and will not be able to use LDAP credentials to access their accounts. </td> </tr> <tr valign="top"> - <th scope="row">Auto-Create WPMU Accounts?</th> + <th scope="row">Enable SSL:</th> <td> - <input type='radio' name='ldapOptionsCreateAcct' id='createAcctYes' value='1' <?php echo $tAcctChecked ?>/> <label for="createAcctYes">Yes</label> - <input type='radio' name='ldapOptionsCreateAcct' id='createAcctNo' value='0' <?php echo $fAcctChecked ?>/> <label for="createAcctNo">No</label> - <p>If "Yes", this will automatically create a WPMU account for any user - that successfully authenticates against the LDAP server. The WPMU user - account will be named the same as the LDAP username. - </p><p>If "No", then a - Site Admin must create a WPMU user account for the user to be able to - log in. The WPMU user account must be named the same as the LDAP - username for LDAP authentication to function. - </p> + <input type='radio' name='ldapEnableSSL' id='sslOn' value='1' <?php echo $tEnableSSL ?>/> <label for="sslOn">Yes</label> + <input type='radio' name='ldapEnableSSL' id='sslOff' value='0' <?php echo $fEnableSSL ?>/> <label for="sslOff">No</label> + <br/> + Select yes to connect over ldaps://, Select no to connect over ldap:// </td> </tr> <tr valign="top"> - <th scope="row">Auto-Create WPMU Blogs?</th> + <th scope="row"><label for="serverAddr">Server Address:</label></th> <td> - <input type='radio' name='ldapOptionsCreateBlog' id='createBlogYes' value='1' <?php echo $tBlogChecked; ?>/> <label for="createBlogYes">Yes</label> - <input type='radio' name='ldapOptionsCreateBlog' id='createBlogNo' value='0' <?php echo $fBlogChecked; ?>/> <label for="createBlogNo">No</label> - <p> - If "Yes", this will automatically create a WPMU blog for any user that successfully authenticates against the LDAP server. The blog will be named the same as the LDAP username. - </p><p> - If "No", then a Site Admin must create a WPMU blog for the user to be able to log in. - </p> + <input type='text' name='ldapServerAddr' id='serverAddr' value='<?php echo $ldapServerAddr ?>' style='width: 300px;' /> + <br/> + The name or IP address of the LDAP server. The protocol should be left out. (Ex. ldap.example.com) </td> </tr> <tr valign="top"> - <th scope="row">Disable Public Signup?</th> + <th scope="row"><label for="serverPort">LDAP Server Port:</label></th> <td> - <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupYes' value='1' <?php echo $tDisableSignup; ?>/> <label for="disableSignupYes">Yes</label> - <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupNo' value='0' <?php echo $fDisableSignup; ?>/> <label for="disableSignupNo">No</label> + <input type='text' name='ldapServerPort' id='serverPort' value='<?php echo $ldapServerPort ?>' style='width: 300px;' /> <br/> - This overrides all actions that take place within wp-signup.php, effectively disabling public signup. + Port Number of the LDAP server. (LDAP: Linux=389, Windows=3268) (LDAPS: Linux=686, Windows=3269) </td> </tr> <tr valign="top"> - <th scope="row">Create local users?</th> + <th scope="row"><label for="serverOU">Search DN:</label></th> <td> - <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserYes' value='1' <?php echo $tCreateLocalUser ?>/> <label for="createLocalUserYes">Yes</label> - <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserNo' value='0' <?php echo $fCreateLocalUser ?>/> <label for="createLocalUserNo">No</label> + <input type='text' name='ldapServerOU' id='serverOU' value='<?php echo $ldapServerOU; ?>' style='width: 450px;' /> <br/> - This will either allow or disallow the creation of local accounts. + The base DN in which to carry out LDAP searches. </td> </tr> <tr valign="top"> - <th scope="row"><label for="ldapSignupMessage">Signup-Disabled Message:</label></th> + <th scope="row"><label for="serverCN">Search User DN:</label></th> <td> - <textarea name='ldapSignupMessage' id='ldapSignupMessage'><?php echo $ldapSignupMessage ?></textarea> - <br/> - This is an alternate HTML message that would be displayed in place of any actions at wp-signup.php. + <input type='text' name='ldapServerCN' id='serverCN' value='<?php echo $ldapServerCN; ?>' style='width: 450px;' /> + <br/> + Some systems do not allow anonymous searching for attributes, and so this will set the account to use when connecting for searches. </td> </tr> <tr valign="top"> - <th scope="row"><label for="ldapGetPasswordMessage">Lost-Password Message:</label></th> + <th scope="row"><label for='serverPass'>Search User Password:</label></th> <td> - <textarea name='ldapGetPasswordMessage' id='ldapGetPasswordMessage'><?php echo $ldapGetPasswordMessage ?></textarea> + <input type='password' name='ldapServerPass' id='serverPass' value='<?php echo $ldapServerPass; ?>' /> <br/> - This is the error message that would be displayed when an LDAP-account user submits "Lost Password" requests. + Password for the User DN above. </td> </tr> <tr valign="top"> - <th scope="row">Allow blog admins to bulk add?</th> + <th scope="row">LDAP Type:</th> <td> - <input type='radio' name='ldapOptionsBulkAdd' id='bulkaddyes' value='1' <?php echo $tBulkAdd; ?>/> <label for="bulkaddyes">Yes</label> - <input type='radio' name='ldapOptionsBulkAdd' id='bulkaddno' value='0' <?php echo $fBulkAdd; ?>/> <label for="bulkaddno">No</label> + <input type='radio' name='ldapLinuxWindows' id='linux' value='1' <?php echo $tLinWin; ?>/> <label for="linux">Linux</label> + <input type='radio' name='ldapLinuxWindows' id='windows' value='0' <?php echo $fLinWin; ?>/> <label for="windows">Windows</label> </td> </tr> + <tr valign="top"> + <th scope="row">Test Connection:</th> + <td> + <input type='radio' name='ldapTestConnection' id='testconnectionyes' value='1'> <label for="textconnectionyes">Yes</label> + <input type='radio' name='ldapTestConnection' checked='checked' id='testconnectionno' value='0'> <label for="textconnectionno">No</label> + <br/> + Specifys whether or not to test the ldap server connection on form submit. + </td> + </tr> </table> - <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save" /></p> + <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save Options" /></p> </form> -</div> <?php } +function ldapOptionsPanelUpdates() { +?> + <form method="post" id="ldap_fix_meta"> + <h3>Upgrade</h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('Update Meta'); ?></th> + <td> + WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. + </td> + </tr> + </table> + <p class="submit"> + <?php echo $ldapfixmeta ?> + <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> + </p> + </form> +<?php +} + +function ldapOptionsPanelAttributes() { + +} + /** * Adds a sub menu to the Site Admin panel. If the currently logged in user is * a site-admin, then this menu is created using the ldapOptionsPanel function. Modified: trunk/ldap/public/ldap_auth.css =================================================================== --- trunk/ldap/public/ldap_auth.css 2009-03-04 03:38:06 UTC (rev 66) +++ trunk/ldap/public/ldap_auth.css 2009-03-07 22:27:31 UTC (rev 67) @@ -1,35 +1,3 @@ -.row { - overflow: hidden; - padding-top: 10px; - width: 800px; -} - -.description { - float: left; - width: 240px; - text-align: right; - font-weight: bold; -} - -.element { - float: right; - text-align: left; - width: 550px; -} - -.more-info { - clear: right; - float: right; - text-align: left; - width: 550px; - font-style: italic; -} - - -textarea#ldapSignupMessage, textarea#ldapGetPasswordMessage { - width: 530px; - height: 50px; -} #wpmuLdapAdminRequest { font-size: 1.2em; font-weight: bold; @@ -46,3 +14,7 @@ .ldapmeta { color: red; } +.wpmuLdapOptionMenuSelected { + text-decoration: none; + font-weight: bold; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-04 03:38:13
|
Revision: 66 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=66&view=rev Author: axelseaa Date: 2009-03-04 03:38:06 +0000 (Wed, 04 Mar 2009) Log Message: ----------- added ability to bulk add users - thanks bforchhammer Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap_adduser.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/wpmu_ldap_adduser.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2009-03-03 04:11:59 UTC (rev 65) +++ trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2009-03-04 03:38:06 UTC (rev 66) @@ -14,19 +14,21 @@ function ldapAddUserResult($options) { extract($options); + if (!empty($username)) + $user = '<b>'.$username.'</b>'; if ( $updated == 'true' ) { ?> <div id="message" class="updated fade"><p> <?php switch ($action) { case 'delete': - _e('User deleted !'); + printf(__('User %s deleted!'),$user); break; case 'add': - _e('User added !'); + printf(__('User %s added!'),$user); break; case 'exists': - _e('User exists !'); + printf(__('User %s exists!'),$user); break; default: _e('Options saved !'); @@ -41,16 +43,16 @@ <?php switch ($action) { case 'exists': - _e('User exists !'); + printf(__('User %s exists!'),$user); break; case 'notfound': - _e('User not found in LDAP Directory !'); + printf(__('User %s not found in LDAP Directory!'),$user); break; case 'add': - _e('Error adding user !'); + printf(__('Error adding user %s!'),$user); break; default: - _e('Error !'); + _e('Error!'); break; } ?> @@ -60,7 +62,7 @@ } function ldapAddUserOptions() { - global $wp_roles, $blog_id, $current_user; + global $blog_id, $current_user; if ($_POST['addUser']) { // Process the post request @@ -76,7 +78,7 @@ $result = wpmuLdapSearchUser($username,$blog_id,$user['new_role']); $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); if ($result[0]) { - ldapAddUserResult(array('updated' => 'true','action' => 'add')); + ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); } elseif ($ldapCreateLocalUser || is_site_admin($current_user->username)) { ?> <div id='message' class='updated'> @@ -90,17 +92,48 @@ </form></p> </div> <?php - } else { - ldapAddUserResult(array('updated' => 'false','action' => 'notfound')); + ldapAddUserResult(array('updated' => 'false','action' => 'notfound','username' => $username)); } } else { // Add User to Blog if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['new_role'])) - ldapAddUserResult(array('updated' => 'true','action' => 'add')); + ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); else - ldapAddUserResult(array('updated' => 'false','action' => 'exists')); + ldapAddUserResult(array('updated' => 'false','action' => 'exists','username' => $username)); } + } elseif ($_POST['addUserBulk']) { + // Check Access + if (!is_site_admin($current_user->username)) { + ldapAddUserResult(array('updated' => 'false','action' => 'auth')); + } else { + $user = $_POST['user']; + $usernames = array(); + if ( !empty($user['bulk_username']) ) { + $usernames = explode("\n", $user['bulk_username']); + $usernames = array_filter(array_map('trim', $usernames)); // trim whitespace from usernames and remove empty lines + $usernames = array_map('strtolower', $usernames); + } + + foreach ($usernames as $username) { + // try finding a WP account for this user name + $login = get_userdatabylogin($username); + if (!$login) { + $result = wpmuLdapSearchUser($username,$blog_id,$user['bulk_new_role']); + if ($result[0]) { + ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); + } else { + ldapAddUserResult(array('updated' => 'false','action' => 'notfound','username' => $username)); + } + } else { + // Add User to Blog + if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['bulk_new_role'])) + ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $username)); + else + ldapAddUserResult(array('updated' => 'false','action' => 'exists','username' => $username)); + } + } + } } elseif ($_POST['addLocalUser']) { check_admin_referer('add-local-user'); $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); @@ -129,7 +162,7 @@ // Configure User Role add_user_to_blog($blog_id, $user_id, $user['role']); - ldapAddUserResult(array('updated' => 'true','action' => 'add')); + ldapAddUserResult(array('updated' => 'true','action' => 'add','username' => $user['username'])); } else { wp_die( __("<p>Access denied.</p>") ); } @@ -140,19 +173,13 @@ <h2><?php _e('Add User') ?></h2> <?php $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); - if (is_site_admin($current_user->username)) { - echo "<div id='wpmuLdapAdminRequest'>Admin Mode Activated"; - if (!$ldapCreateLocalUser) { - echo "<p>Local User Creation Enabled</p>"; - } - echo "</div>"; - } + if ($ldapCreateLocalUser) { + echo "<p>Local User Creation Enabled</p>"; + } ?> <p> Using the following fields below to search out LDAP users and add them into the blog. - <?php - if ($ldapCreateLocalUser) { - ?> + <?php if ($ldapCreateLocalUser) { ?> If the user does not exist in the LDAP Directory, you will have the option to create a local account for them. <?php } ?> </p> @@ -167,22 +194,54 @@ </tr> <tr valign="top"> <th scope="row"><label for="new_role"><?php _e('Role:') ?></label></th> - <td><select name="user[new_role]" id="new_role"><?php - foreach($wp_roles->role_names as $role => $name) { - $selected = ''; - if( $role == 'subscriber' ) - $selected = 'selected="selected"'; - echo "<option {$selected} value=\"{$role}\">{$name}</option>"; - } - ?></select></td> + <td><?php wpmuLdapAddGenRoleBox('new_role') ?></td> </tr> </table> <p class="submit"> - <input class="button" type="submit" name="addUser" value="<?php _e('Add user') ?>" /> + <input class="button" type="submit" name="addUser" value="<?php _e('Add User') ?>" /> </p> </fieldset> </form> + + <!-- Bulk Add User --> + <?php + $ldapBulkAdd = get_site_option('ldapBulkAdd'); + if (is_site_admin($current_user->username) || ($ldapBulkAdd && is_admin($current_user->username))) { + ?> + <h2><?php _e('Add Bulk Users') ?></h2> + <p>Using the below fields, you can bulk add LDAP users. Separate multiple users by a new line. Local user creation is not available in bulk.</p> + <form method="post" id="ldap_add_user_bulk"> + <?php wp_nonce_field('add-user-bulk') ?> + <fieldset class="options"> + <table class="form-table" cellpadding="3" cellspacing="3"> + <tr valign="top"> + <th scope='row'><label for="addbulkusername"><?php _e('Usernames:') ?></label></th> + <td><textarea name="user[bulk_username]" id="addbulkusername" rows="15" cols="40"></textarea></td> + </tr> + <tr valign="top"> + <th scope="row"><label for="bulk_new_role"><?php _e('Role:') ?></label></th> + <td><?php wpmuLdapAddGenRoleBox('bulk_new_role') ?></td> + </tr> + </table> + <p class="submit"> + <input class="button" type="submit" name="addUserBulk" value="<?php _e('Add User Bulk') ?>" /> + </p> + </fieldset> + </form> + <?php } ?> </div> <?php } -?> + +function wpmuLdapAddGenRoleBox($id) { + global $wp_roles; + echo '<select name="user['.$id.']" id="'.$id.'">'; + foreach($wp_roles->role_names as $role => $name) { + $name = translate_with_context($name); + $selected = ''; + if( $role == 'subscriber' ) + $selected = 'selected="selected"'; + echo "<option {$selected} value=\"{$role}\">{$name}</option>"; + } + echo '</select>'; +} Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-03 04:11:59 UTC (rev 65) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-04 03:38:06 UTC (rev 66) @@ -19,6 +19,58 @@ * @return null - does not actively return a value * @see ldap_addmenu */ +function newldapOptionsPanel() { + global $current_blog; + $tab = $_GET['ldaptab']; + $allowedtabs = array('general','attributes','updates'); +?> +<div class="wrap"> + <h2><?php _e('Ldap Authentication Options'); ?></h2> + <hr/> + <p>General Settings | Attribute Mapping | Upgrade</p> + <hr/> + + <?php + if ($tab == 'attributes') { + + } elseif ($tab == 'upgrade') { + ldapOptionsPanelUpdates(); + } else { + + } + ?> +</div> +<?php +} + +function ldapOptionsPanelGeneral() { + +} + +function ldapOptionsPanelUpdates() { +?> + <form method="post" id="ldap_fix_meta"> + <h3>Upgrade</h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('Update Meta'); ?></th> + <td> + WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. + </td> + </tr> + </table> + <p class="submit"> + <?php echo $ldapfixmeta ?> + <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> + </p> + </form> +<?php +} + +function ldapOptionsPanelAttributes() { + +} + function ldapOptionsPanel() { global $current_blog; if($_POST['ldapOptionsSave']) { @@ -32,6 +84,7 @@ update_site_option('ldapServerCN', $_POST['ldapOptionsServerCN']); update_site_option('ldapServerPass', $_POST['ldapOptionsServerPass']); update_site_option('ldapEnableSSL', $_POST['ldapOptionsEnableSSL']); + update_site_option('ldapBulkAdd', $_POST['ldapOptionsBulkAdd']); update_site_option('ldapDisableSignup', $_POST['ldapOptionsDisableSignup']); update_site_option('ldapCreateLocalUser', $_POST['ldapOptionsCreateLocalUser']); update_site_option('ldapSignupMessage', stripslashes($_POST['ldapSignupMessage'])); @@ -70,6 +123,7 @@ $ldapSignupMessage = stripslashes(get_site_option('ldapSignupMessage', $defaultSignupMessage)); $ldapGetPasswordMessage = stripslashes(get_site_option('ldapGetPasswordMessage', $defaultGetPasswordMessage)); $ldapfixmetafor15 = get_site_option('ldapfixmetafor15'); + $ldapBulkAdd = get_site_option('ldapBulkAdd'); // default values to avoid PHP notices about unset values $tChecked = ''; @@ -115,6 +169,13 @@ $fLinWin = "checked='checked'"; } + if($ldapBulkAdd) { + $tBulkAdd = "checked='checked'"; + } + else { + $fBulkAdd = "checked='checked'"; + } + if($ldapEnableSSL) { $tEnableSSL = "checked='checked'"; } @@ -152,29 +213,14 @@ ?> <div class="wrap"> <h2><?php _e('Ldap Authentication Options'); ?></h2> + <p>General Settings | Attribute Mapping | Upgrade</p> <p> To start allowing users to log in with LDAP credentials, you will need to Enable LDAP-Authentication below. LDAP Authentication is available for all accounts. It is recommended that you still maintain a local <strong>admin</strong> account to allow access if the LDAP server is unavailable. </p> - <form method="post" id="ldap_fix_meta"> - <h3>Upgrade</h3> - <table class="form-table"> - <tr valign="top"> - <th scope="row"><?php _e('Update Meta'); ?></th> - <td> - WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. - </td> - </tr> - </table> - <p class="submit"> - <?php echo $ldapfixmeta ?> - <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> - </p> - </form> - <form method="post" id="ldap_auth_options"> <h3>LDAP Settings</h3> <table class="form-table"> @@ -304,7 +350,13 @@ This is the error message that would be displayed when an LDAP-account user submits "Lost Password" requests. </td> </tr> - + <tr valign="top"> + <th scope="row">Allow blog admins to bulk add?</th> + <td> + <input type='radio' name='ldapOptionsBulkAdd' id='bulkaddyes' value='1' <?php echo $tBulkAdd; ?>/> <label for="bulkaddyes">Yes</label> + <input type='radio' name='ldapOptionsBulkAdd' id='bulkaddno' value='0' <?php echo $fBulkAdd; ?>/> <label for="bulkaddno">No</label> + </td> + </tr> </table> <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save" /></p> </form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-03-03 04:12:07
|
Revision: 65 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=65&view=rev Author: axelseaa Date: 2009-03-03 04:11:59 +0000 (Tue, 03 Mar 2009) Log Message: ----------- site admins are now able to change the user authentication role (ldap or local) via dropdown box on user profile page - thanks jlencion Modified Paths: -------------- trunk/ldap/doc/README trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap_auth.php Modified: trunk/ldap/doc/README =================================================================== --- trunk/ldap/doc/README 2009-02-22 17:58:56 UTC (rev 64) +++ trunk/ldap/doc/README 2009-03-03 04:11:59 UTC (rev 65) @@ -1,11 +1,14 @@ ================================================================================ +Project Website: http://wpmuldap.frozenpc.net +================================================================================ +================================================================================ License: ================================================================================ -LDAP-Authentication Plugin, v.1.5 -for WPMU 1.5.x +LDAP-Authentication Plugin, v.2.7 +for WPMU 2.7.x -Copyright (C) 2007 Alistair Young, Patrick Cavit, Hugo Salgado, Alex Barker, and +Copyright (C) 2009 Alistair Young, Patrick Cavit, Hugo Salgado, Alex Barker, and Sean Wedig, Aaron Axelsen This library is free software; you can redistribute it and/or modify it under @@ -132,3 +135,6 @@ Aaron Axelsen - http://www.frozenpc.net +================================================================================ +Project Website: http://wpmuldap.frozenpc.net +================================================================================ Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-02-22 17:58:56 UTC (rev 64) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-03-03 04:11:59 UTC (rev 65) @@ -420,5 +420,55 @@ } } +/** + * Displays the account authentication type options on the edit user form. + */ +function wpmuUserFormLdapOption() { + global $user_id, $current_user; + $ldap_login = get_usermeta($user_id, 'ldap_login'); + ?> +<h3><?php _e('LDAP Options'); ?></h3> -?> +<table class="form-table"> +<tr> + <th><?php _e('Account Authentication Type'); ?></th> + <td class="regular-text"> + <?php if (is_site_admin($current_user->username) && $user_id > 1) { ?> + <select name="ldapAccountType"> + <option<?php if ($ldap_login == 'true') echo ' selected="selected"'; ?> value="LDAP"><?php _e('LDAP'); ?></option> + <option<?php if ($ldap_login != 'true') echo ' selected="selected"'; ?> value="Local"><?php _e('Local'); ?></option> + </select> + <?php } else { + if ($user_id == 1) + $msg = "Userid #1 cannot be changed."; + else + $msg = "Only site admin's can update account type."; + if ($ldap_login == 'true') { + echo "<input type='text' disabled='disabled' value='"._('LDAP')."' />"; + } else { + echo "<input type='text' disabled='disabled' value='"._('Local')."' />"; + } + _e($msg); + } ?> + </td> +</tr> +</table> + <?php +} // wpmuUserFormLdapOption() + +/** + * Updates ldap_auth user meta value based on option selected on the edit user form + */ +function wpmuUserFormLdapOptionUpdate() { + global $user_id, $current_user; + + if ($user_id == 1 || !is_site_admin($current_user->username)) + return; + + if ($_POST['ldapAccountType'] == 'LDAP') + update_usermeta( $user_id, 'ldap_login', 'true' ); + else + delete_usermeta( $user_id, 'ldap_login' ); + +} // wpmuUserFormLdapOptionUpdate() + Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2009-02-22 17:58:56 UTC (rev 64) +++ trunk/ldap_auth.php 2009-03-03 04:11:59 UTC (rev 65) @@ -24,6 +24,10 @@ add_action('admin_menu', 'ldap_addmenu'); add_action('admin_menu', 'ldap_addmenuuser'); +// Add radio buttons for switching individual users between LDAP accounts and non-LDAP accounts +add_action('edit_user_profile', 'wpmuUserFormLdapOption'); +add_action('edit_user_profile_update', 'wpmuUserFormLdapOptionUpdate'); + // *** End Admin Config Functions *** // // *** Begin User Auth Functions *** // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-02-22 17:59:05
|
Revision: 64 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=64&view=rev Author: axelseaa Date: 2009-02-22 17:58:56 +0000 (Sun, 22 Feb 2009) Log Message: ----------- new release Added Paths: ----------- tags/wpmu-ldap_2.7.0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-02-22 17:46:15
|
Revision: 63 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=63&view=rev Author: axelseaa Date: 2009-02-22 17:46:02 +0000 (Sun, 22 Feb 2009) Log Message: ----------- revamped signup disabled handling, thanks bforchhammer Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-15 06:36:59 UTC (rev 62) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-22 17:46:02 UTC (rev 63) @@ -236,14 +236,14 @@ * @author Sean Wedig (www.thecodelife.net) */ function wpmuLdapDisableSignup() { - get_header(); - echo '<div id="content" class="widecolumn">'; + wp_redirect(get_option('siteurl').'/wp-login.php?action=signupdisabled'); $msg = stripslashes(get_site_option('ldapSignupMessage')); - - _e($msg); - echo '</div>'; - get_footer(); - die(); } -?> + +function wpmuLdapDisableSignupMessage() { + if ($_GET['action'] == 'signupdisabled') { + global $error; + $error = '<strong>ERROR:</strong> '.stripslashes(get_site_option('ldapSignupMessage')); + } +} Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-02-15 06:36:59 UTC (rev 62) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2009-02-22 17:46:02 UTC (rev 63) @@ -44,13 +44,8 @@ echo "<div id='message' class='updated fade'><p>All users ldap_auth meta values updated!</p></div>"; } - $defaultSignupMessage = <<<NoSignupMsg -<p><strong>Public sign-up has been disabled.</strong></p> + $defaultSignupMessage = 'Public sign-up has been disabled.'; -<p>If you already have an account, please <a href="wp-login.php">log in</a> and -try again.</p> -NoSignupMsg; - $sysAdminEmail = get_site_option('admin_email'); $defaultGetPasswordMessage = <<<GetPasswordMsg Your account is tied to an account in the central directory. You cannot @@ -344,7 +339,7 @@ $ldap_login = get_usermeta($userID, 'ldap_login'); if ($ldap_login == true) { // get the configurable error message: - return new WP_Error('no_password_reset', __("<strong>ERROR</strong>:").get_site_option('ldapGetPasswordMessage').'.'); + return new WP_Error('no_password_reset', __("<strong>ERROR</strong>: ").get_site_option('ldapGetPasswordMessage')); } } add_filter('allow_password_reset','ldapPasswordReset',0,2); Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2009-02-15 06:36:59 UTC (rev 62) +++ trunk/ldap_auth.php 2009-02-22 17:46:02 UTC (rev 63) @@ -1,9 +1,9 @@ <?php /* Plugin Name: LDAP Authentication Plug-in -Plugin URI: http://sourceforge.net/projects/wpmu-ldap -Description: A plugin to override the core Wordpress MU authentication method (for non-site admins) so as to use an LDAP server for authentication. -Version: 1.5.1 +Plugin URI: http://wpmuldap.frozenpc.net +Description: A plugin to override the core Wordpress MU authentication method so as to use an LDAP server for authentication. +Version: 2.7 Author: Alistair Young (http://www.weblogs.uhi.ac.uk/sm00ay/), Patrick Cavit (http://patcavit.com), Hugo Salgado (http://hugo.vulcano.cl), @@ -28,8 +28,9 @@ // *** Begin User Auth Functions *** // // disable public signup if configured to do so -if (get_site_option("ldapDisableSignup") ) { +if (get_site_option('ldapDisableSignup')) { add_action('signup_header', 'wpmuLdapDisableSignup'); + add_action('login_head', 'wpmuLdapDisableSignupMessage'); } // perform these filters, actions, and WP function overrides only if LDAP- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-02-15 06:37:08
|
Revision: 62 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=62&view=rev Author: axelseaa Date: 2009-02-15 06:36:59 +0000 (Sun, 15 Feb 2009) Log Message: ----------- added strip slashes to allow special characters in passwords - fixes 2580950 Modified Paths: -------------- trunk/ldap/lib/ldap_core.php trunk/ldap/lib/wpmu_ldap.functions.php Modified: trunk/ldap/lib/ldap_core.php =================================================================== --- trunk/ldap/lib/ldap_core.php 2009-02-15 05:48:05 UTC (rev 61) +++ trunk/ldap/lib/ldap_core.php 2009-02-15 06:36:59 UTC (rev 62) @@ -69,7 +69,7 @@ $this->error_no = 0; $this->error_txt = "Success"; $return = false; - + $this->dn_passwd = stripslashes($this->dn_passwd); if ($this->connection_handle) { if ($this->debug) { if (ldap_bind ($this->connection_handle, $this->dn, $this->dn_passwd)) { Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-15 05:48:05 UTC (rev 61) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-15 06:36:59 UTC (rev 62) @@ -63,7 +63,6 @@ $errors = new WP_Error; $server = new LDAP_ro($ldapString); $server->DebugOff(); - // undefined now - going to populate it in $server->Authenticate $userDataArray = null; $result = $server->Authenticate ($loginUserName, $loginPassword, $userDataArray); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-02-15 05:48:14
|
Revision: 61 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=61&view=rev Author: axelseaa Date: 2009-02-15 05:48:05 +0000 (Sun, 15 Feb 2009) Log Message: ----------- change ldap string to array based - fixed ldap strings which had colons - thanks gravelpot Modified Paths: -------------- trunk/ldap/lib/ldap_core.php trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/ldap_core.php =================================================================== --- trunk/ldap/lib/ldap_core.php 2009-02-10 04:05:26 UTC (rev 60) +++ trunk/ldap/lib/ldap_core.php 2009-02-15 05:48:05 UTC (rev 61) @@ -25,14 +25,13 @@ var $port; var $debug; - function LDAP($in_server) { - $parts = split (":", $in_server); - $this->server = $parts[SERVER_NAME]; - $this->search_dn = $parts[SEARCH_BASE]; - $this->dn = $parts[PRIV_DN]; - $this->dn_passwd = $parts[PRIV_PASSWD]; - $this->usessl = $parts[ENABLE_SSL]; - $this->port = $parts[SERVER_PORT]; + function LDAP($options = array()) { + $this->server = $options[SERVER_NAME]; + $this->search_dn = $options[SEARCH_BASE]; + $this->dn = $options[PRIV_DN]; + $this->dn_passwd = $options[PRIV_PASSWD]; + $this->usessl = $options[ENABLE_SSL]; + $this->port = $options[SERVER_PORT]; } function Connect() { Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-10 04:05:26 UTC (rev 60) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-15 05:48:05 UTC (rev 61) @@ -157,7 +157,7 @@ /** * Searches the LDAP directory for the specified user */ -function wpmuLdapSearch($ldapString,$in_username,&$userDataArray) { +function wpmuLdapSearch($ldapString = array(),$in_username,&$userDataArray) { $server = new LDAP_ro($ldapString); $server->DebugOff(); @@ -177,7 +177,7 @@ */ function wpmuLdapSearchUser($username,$blog_id = 1,$new_role = 'subscriber',$createUser = true) { // Bind to directory, search for username - $ldapString = wpmuSetupLdapString(); + $ldapString = wpmuSetupLdapOptions(); $userDataArray = null; if (wpmuLdapSearch($ldapString,$username,$userDataArray)) { if ($createUser) { @@ -212,18 +212,17 @@ } /** - * Configures the ldapString to pass in for authentication/verification + * Configures the ldap options to pass in for authentication/verification */ -function wpmuSetupLdapString() { - $ldapCookieMarker = get_site_option("ldapCookieMarker"); - $ldapServerAddr = get_site_option("ldapServerAddr"); - $ldapServerOU = get_site_option("ldapServerOU"); - $ldapServerCN = get_site_option("ldapServerCN"); - $ldapServerPass = get_site_option("ldapServerPass"); - $ldapServerPort = get_site_option("ldapServerPort"); - $ldapEnableSSL = get_site_option("ldapEnableSSL"); - - return("$ldapServerAddr:$ldapServerOU:$ldapServerCN:$ldapServerPass:$ldapServerPort:$ldapEnableSSL"); +function wpmuSetupLdapOptions() { + $options = array(); + $options[] = get_site_option("ldapServerAddr"); + $options[] = get_site_option("ldapServerOU"); + $options[] = get_site_option("ldapServerCN"); + $options[] = get_site_option("ldapServerPass"); + $options[] = get_site_option("ldapServerPort"); + $options[] = get_site_option("ldapEnableSSL"); + return $options; } /** Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2009-02-10 04:05:26 UTC (rev 60) +++ trunk/ldap_auth.php 2009-02-15 05:48:05 UTC (rev 61) @@ -55,7 +55,7 @@ $ldapAuth = get_site_option("ldapAuth"); // setup ldap string - $ldapString = wpmuSetupLdapString(); + $ldapString = wpmuSetupLdapOptions(); // try finding a WP account for this user name $user = get_userdatabylogin($username); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2009-02-10 04:05:36
|
Revision: 60 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=60&view=rev Author: axelseaa Date: 2009-02-10 04:05:26 +0000 (Tue, 10 Feb 2009) Log Message: ----------- minor changes for wpmu 2.7 - fixes 2548697 Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_adduser.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2008-10-21 03:04:40 UTC (rev 59) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2009-02-10 04:05:26 UTC (rev 60) @@ -28,7 +28,7 @@ update_usermeta( $user_id, 'ldap_login', 'true' ); //This is for plugin events - do_action('wpmu_activate_user', $user_id, $newUserPassword); + do_action('wpmu_activate_user', $user_id, $newUserPassword, false); $domain = strtolower( wp_specialchars( $newUserName ) ); if( constant( "VHOST" ) == 'yes' ) { @@ -55,8 +55,6 @@ do_action('wpmu_activate_blog', $blog_id, $user_id, $newUserPassword, $newUserName . "'s blog", $meta); } - //Must recreated the login object for our shiny NEW users. - #return get_userdatabylogin($newUserName); return new WP_User($user_id); } @@ -139,12 +137,11 @@ } // Handle blog removal for various reasons - $primary_blog = get_usermeta( $loginObj->ID, "primary_blog" ); - if( $primary_blog ) { + if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $loginObj->ID, "primary_blog" ) ) ) { $details = get_blog_details( $primary_blog ); if( is_object( $details ) ) { if( $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - add_user_to_blog('1',$loginObj->ID,'subscriber'); + add_user_to_blog('1',$loginObj->ID,'subscriber'); #return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } Modified: trunk/ldap/lib/wpmu_ldap_adduser.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2008-10-21 03:04:40 UTC (rev 59) +++ trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2009-02-10 04:05:26 UTC (rev 60) @@ -12,13 +12,13 @@ } } -function ldapAddUserOptions() { - global $wp_roles, $blog_id, $current_user; - if ( $_GET['updated'] == 'true' ) { +function ldapAddUserResult($options) { + extract($options); + if ( $updated == 'true' ) { ?> <div id="message" class="updated fade"><p> <?php - switch ($_GET['action']) { + switch ($action) { case 'delete': _e('User deleted !'); break; @@ -35,11 +35,11 @@ ?> </p></div> <?php - } elseif ( $_GET['updated'] == 'false' ) { + } elseif ( $updated == 'false' ) { ?> <div id="message" class="error fade"><p> <?php - switch ($_GET['action']) { + switch ($action) { case 'exists': _e('User exists !'); break; @@ -57,7 +57,11 @@ </p></div> <?php } +} +function ldapAddUserOptions() { + global $wp_roles, $blog_id, $current_user; + if ($_POST['addUser']) { // Process the post request $user = $_POST['user']; @@ -72,8 +76,7 @@ $result = wpmuLdapSearchUser($username,$blog_id,$user['new_role']); $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); if ($result[0]) { - wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) ); - exit(); + ldapAddUserResult(array('updated' => 'true','action' => 'add')); } elseif ($ldapCreateLocalUser || is_site_admin($current_user->username)) { ?> <div id='message' class='updated'> @@ -89,18 +92,14 @@ <?php } else { - wp_redirect( add_query_arg( array('updated' => 'false', 'action' => 'notfound'), $_SERVER['HTTP_REFERER'] ) ); - exit(); + ldapAddUserResult(array('updated' => 'false','action' => 'notfound')); } } else { // Add User to Blog - if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['new_role'])) { - wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) ); - exit(); - } - - wp_redirect( add_query_arg( array('updated' => 'false', 'action' => 'exists'), $_SERVER['HTTP_REFERER'] ) ); - exit(); + if (wpmuLdapAddUserToBlog($login->ID,$blog_id,$user['new_role'])) + ldapAddUserResult(array('updated' => 'true','action' => 'add')); + else + ldapAddUserResult(array('updated' => 'false','action' => 'exists')); } } elseif ($_POST['addLocalUser']) { check_admin_referer('add-local-user'); @@ -130,8 +129,7 @@ // Configure User Role add_user_to_blog($blog_id, $user_id, $user['role']); - wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) ); - exit(); + ldapAddUserResult(array('updated' => 'true','action' => 'add')); } else { wp_die( __("<p>Access denied.</p>") ); } Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-10-21 03:04:40 UTC (rev 59) +++ trunk/ldap_auth.php 2009-02-10 04:05:26 UTC (rev 60) @@ -68,7 +68,7 @@ if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $user->ID, "primary_blog" ) ) ) { $details = get_blog_details( $primary_blog ); if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - add_user_to_blog('1',$user->ID,'subscriber'); + add_user_to_blog('1',$user->ID,'subscriber'); #return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-10-21 03:04:59
|
Revision: 59 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=59&view=rev Author: axelseaa Date: 2008-10-21 03:04:40 +0000 (Tue, 21 Oct 2008) Log Message: ----------- fixes potential issues were a non siteadmin user that has multiple blogs will be denied login if the primary blog is flagged as 'suspended' Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2008-08-01 17:02:14 UTC (rev 58) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2008-10-21 03:04:40 UTC (rev 59) @@ -144,7 +144,8 @@ $details = get_blog_details( $primary_blog ); if( is_object( $details ) ) { if( $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); + add_user_to_blog('1',$loginObj->ID,'subscriber'); + #return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } } else { Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-08-01 17:02:14 UTC (rev 58) +++ trunk/ldap_auth.php 2008-10-21 03:04:40 UTC (rev 59) @@ -68,7 +68,8 @@ if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $user->ID, "primary_blog" ) ) ) { $details = get_blog_details( $primary_blog ); if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); + add_user_to_blog('1',$user->ID,'subscriber'); + #return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } else { // If user does not have a primary blog, set them as a subscriber to blog 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-08-01 17:02:17
|
Revision: 58 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=58&view=rev Author: axelseaa Date: 2008-08-01 17:02:14 +0000 (Fri, 01 Aug 2008) Log Message: ----------- locking in 2.6 release Added Paths: ----------- tags/wpmu-ldap_2.6.0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-07-27 20:48:16
|
Revision: 57 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=57&view=rev Author: axelseaa Date: 2008-07-27 20:48:14 +0000 (Sun, 27 Jul 2008) Log Message: ----------- minor tweaks on admin forms - also implemented new password reset hooks that are available in the wpmu trunk (to be included in the 2.6 release) Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-18 19:49:52 UTC (rev 56) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-27 20:48:14 UTC (rev 57) @@ -170,13 +170,13 @@ <th scope="row"><?php _e('Update Meta'); ?></th> <td> WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. - <p class="submit"> - <?php echo $ldapfixmeta ?> - <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> - </p> </td> </tr> </table> + <p class="submit"> + <?php echo $ldapfixmeta ?> + <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> + </p> </form> @@ -335,61 +335,19 @@ } } -/** We have no desire to manage or manipulate the LDAP password, so the "lost - * password" action doesn't make sense for LDAP accounts; so work around it - */ -function ldapRetrievePassword($userName) { - $login = get_userdatabylogin($userName); - $ldap_login = get_usermeta($login->ID, 'ldap_login'); - - if ($ldap_login == true) { - // get the configurable error message: - $getPwdMessage = get_site_option('ldapGetPasswordMessage'); - - $pwderror = __("<strong>ERROR</strong>: $getPwdMessage"); - login_header(__('Lost Password')); - - // HACK: Just shows a cut-n-paste of the login form as a workaround, since actions do not allow us to cease execution (e.g., by returning false), so need to display the form with the error message -?> -<div id="login_error"><?php echo $pwderror ?></div> -<ul> -<?php if (get_option('users_can_register')) : ?> - <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> - <li><a href="<?php bloginfo('wpurl'); ?>/signup/"><?php _e('Register') ?></a></li> - <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), -get_bloginfo('title')); -?></a></li> -<?php else : ?> - <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), -get_bloginfo('title')); -?></a></li> - <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> -<?php endif; ?> -</ul> -</body> -</html> -<?php - die(); - } else { - return true; - } -} -add_action('retrieve_password', 'ldapRetrievePassword'); - /** - * New proposed solution for retrieve password - pending patch implementation by WP team. + * Checks to see if user is allowed to reset password. If the user has the ldap_login meta set + * the global password recovery message will be display back to the user. Local accounts will + * still retain the ability to reset their passwords. */ -function ldapRetrievePasswordError($userID,$pass_error) { - #$login = get_userdatabylogin($userName); - #$ldap_login = get_usermeta($login->ID, 'ldap_login'); +function ldapPasswordReset($value,$userID) { $ldap_login = get_usermeta($userID, 'ldap_login'); - if ($ldap_login == true) { // get the configurable error message: - $pass_error = get_site_option('ldapGetPasswordMessage'); + return new WP_Error('no_password_reset', __("<strong>ERROR</strong>:").get_site_option('ldapGetPasswordMessage').'.'); } } -#add_action('retrieve_password_error', 'ldapRetrievePasswordError',10,2); +add_filter('allow_password_reset','ldapPasswordReset',0,2); /** * Returns false if LDAP authentication is turned on, the current user is a site This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-07-18 19:49:56
|
Revision: 56 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=56&view=rev Author: axelseaa Date: 2008-07-18 19:49:52 +0000 (Fri, 18 Jul 2008) Log Message: ----------- freshened up the admin interface, changed if block in ldap_auth, updated readme a bit Modified Paths: -------------- trunk/ldap/doc/README trunk/ldap/lib/wpmu_ldap_adduser.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap/public/ldap_auth.css trunk/ldap_auth.php Modified: trunk/ldap/doc/README =================================================================== --- trunk/ldap/doc/README 2008-07-18 15:51:49 UTC (rev 55) +++ trunk/ldap/doc/README 2008-07-18 19:49:52 UTC (rev 56) @@ -2,8 +2,8 @@ License: ================================================================================ -LDAP-Authentication Plugin, v.1.3.0 -for WPMU 1.2.1 / 1.2.3 +LDAP-Authentication Plugin, v.1.5 +for WPMU 1.5.x Copyright (C) 2007 Alistair Young, Patrick Cavit, Hugo Salgado, Alex Barker, and Sean Wedig, Aaron Axelsen @@ -26,8 +26,8 @@ Description: ================================================================================ -A plugin to override the core Wordpress MU authentication method (for non-site -admins) so as to use an LDAP server for authentication. +A plugin to override the core Wordpress MU authentication method so as to use an +LDAP server for authentication. Once installed (see below for instructions), the system may be configured to automatically create local WordPress MU user accounts and blogs. Both the @@ -53,17 +53,8 @@ Installtion: ================================================================================ -Extract to your <wordpressmu_root/wp-content/mu-plugins> folder, overwriting -the pluggable.php file that should already exist. +Extract to your <wordpressmu_root/wp-content/mu-plugins> folder. Thats it! -WARNING! Overwriting pluggable.php may not be a consistently good idea for all -versions of WPMU, but is unfortunately necessary for the functioning of this -plugin (before WPMU version 1.3, anyway). This plugin relies on the ability to -override core methods of WPMU, and so requires modification. Please confirm -for yourself that code being overwritten is properly represented in the version -of pluggable.php, and handle merging appropriately if not. (Better still, -merge the changes and share the new version of pluggable.php for everyone else!) - It is recommended to also change the welcome message that is sent to users upon account creation. By default, WPMU includes the user's password in the message, even though this password is *not* used by this plugin. The password sent is @@ -71,6 +62,7 @@ login. To change the welcome message, log in as a Site Admin and go to Site Admin -> Options, and edit "Welcome Email" appropriately. + ================================================================================ Configuration: ================================================================================ @@ -117,7 +109,6 @@ unable to log in unless their passwords are reset. - ================================================================================ Credits: ================================================================================ @@ -139,5 +130,5 @@ Sean Wedig - http://www.thecodelife.net/category/software-dev/technology/wpmu/wpmu-ldap/ -Aaron Axelsen - \ No newline at end of file +Aaron Axelsen - http://www.frozenpc.net + Modified: trunk/ldap/lib/wpmu_ldap_adduser.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2008-07-18 15:51:49 UTC (rev 55) +++ trunk/ldap/lib/wpmu_ldap_adduser.functions.php 2008-07-18 19:49:52 UTC (rev 56) @@ -160,16 +160,15 @@ </p> <form method="post" id="ldap_add_user"> - + <?php wp_nonce_field('add-user') ?> <fieldset class="options"> - - <table cellpadding="3" cellspacing="3"> - <tr> - <th style="text-align:center;" scope='row'><?php _e('Username:') ?></th> - <td><input type="text" name="user[username]" /></td> + <table class="form-table" cellpadding="3" cellspacing="3"> + <tr valign="top"> + <th scope='row'><label for="addusername"><?php _e('Username:') ?></label></th> + <td><input type="text" id="addusername" name="user[username]" /></td> </tr> - <tr> - <th scope="row"><?php _e('Role:') ?></th> + <tr valign="top"> + <th scope="row"><label for="new_role"><?php _e('Role:') ?></label></th> <td><select name="user[new_role]" id="new_role"><?php foreach($wp_roles->role_names as $role => $name) { $selected = ''; @@ -180,16 +179,12 @@ ?></select></td> </tr> </table> - <p> - <?php wp_nonce_field('add-user') ?> - <input class="button" type="submit" name="addUser" value="<?php _e('Add user') ?>" /></p> - + <p class="submit"> + <input class="button" type="submit" name="addUser" value="<?php _e('Add user') ?>" /> + </p> </fieldset> - </form> - </div> - <?php } ?> Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-18 15:51:49 UTC (rev 55) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-18 19:49:52 UTC (rev 56) @@ -40,7 +40,7 @@ echo "<div id='message' class='updated fade'><p>Saved Options!</p></div>"; } else if ($_POST['ldapFixMeta']) { wpmuLdapFixMeta(); - + update_site_option('ldapfixmetafor15','true'); echo "<div id='message' class='updated fade'><p>All users ldap_auth meta values updated!</p></div>"; } @@ -74,6 +74,7 @@ $ldapCreateLocalUser = get_site_option('ldapCreateLocalUser'); $ldapSignupMessage = stripslashes(get_site_option('ldapSignupMessage', $defaultSignupMessage)); $ldapGetPasswordMessage = stripslashes(get_site_option('ldapGetPasswordMessage', $defaultGetPasswordMessage)); + $ldapfixmetafor15 = get_site_option('ldapfixmetafor15'); // default values to avoid PHP notices about unset values $tChecked = ''; @@ -140,6 +141,11 @@ $fCreateLocalUser = "checked='checked'"; } + if(!empty($ldapfixmetafor15)) { + $ldapfixmeta = "<span class='ldapmeta'>This has already been run, are you sure you want to fix meta again?</span><br/><br/>"; + } else { + $ldapfixmeta = ''; + } if (!is_numeric($ldapServerPort)) { $ldapServerPort = 389; @@ -148,37 +154,9 @@ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; $moreInfoImgUrl = $schema.$current_blog->domain.$current_blog->path."wp-content/mu-plugins/ldap/public/more-info.gif"; - echo <<<LdapForm - - <script type="text/javascript"> - //<![CDATA[ - /* Look for element, and if it's visible, hide it. If not, show it. */ - function toggleShow(element) { - $$(element) - .each(function (infobox) { - if (infobox.visible()) - infobox.hide(); - else - infobox.show(); - } - ); - } - - function toggleDisable(element) { - $$(element).each(function (input) { input.disabled = !input.disabled; } ); - } - - /* Hide all elements of class "more-info". */ - function hideMoreInfo() { - $$('.more-info').each(function(item) {item.hide()}); - } - - addLoadEvent(hideMoreInfo); - //]]> - </script> - - <div class="wrap"> - <h2>Ldap Authentication Options</h2> +?> +<div class="wrap"> + <h2><?php _e('Ldap Authentication Options'); ?></h2> <p> To start allowing users to log in with LDAP credentials, you will need to Enable LDAP-Authentication below. LDAP Authentication is available for all @@ -186,242 +164,157 @@ account to allow access if the LDAP server is unavailable. </p> <form method="post" id="ldap_fix_meta"> - <fieldset class="options"> - <div class="row"> - <span class="description"> - Update ldap_login meta - </span> - <span class="element"> - <input type="submit" name="ldapFixMeta" value="Fix" /> - </span> - <span class="more-info"> - Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. - If you have local users, this will also change them. This is only needed for those users upgrading from the - 1.3 series of wordpress. - </span> - </div> - </fieldset> + <h3>Upgrade</h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row"><?php _e('Update Meta'); ?></th> + <td> + WARNING: Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. If you have local users, this will also change them. This is only needed for those users upgrading from the 1.3 series of wordpress. + <p class="submit"> + <?php echo $ldapfixmeta ?> + <input type="submit" name="ldapFixMeta" value="Fix Meta (Required if upgrading from WPMU 1.3)"/> + </p> + </td> + </tr> + </table> </form> <form method="post" id="ldap_auth_options"> - - <fieldset class="options"> - <div class="row" id="ldapOptionsAuth"> - <span class="description"> - LDAP-Authentication is...? - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsAuth .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsAuth' id='authEnable' value='1' $tChecked/> <label for="authEnable">Enabled</label> - <input type='radio' name='ldapOptionsAuth' id='authDisable' value='0' $fChecked/> <label for="authDisable">Disabled</label> - </span> - - <span class="more-info"> - If this is disabled, then entire plugin will be disabled. Users will - need to log in using WPMU user credentials, and will not be able to use - LDAP credentials to access their accounts. - </span> - </div> - </fieldset> - - - <fieldset id="ldap-specifics" class="options"> - <legend>LDAP Server Connection Information</legend> - - <div class="row" id="ldapOptionsServerSSL"> - <span class="description"> - Enable LDAP over SSL: - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerSSL .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsEnableSSL' id='sslOn' value='1' $tEnableSSL /> <label for="sslOn">Yes</label> - <input type='radio' name='ldapOptionsEnableSSL' id='sslOff' value='0' $fEnableSSL /> <label for="sslOff">No</label> - </span> - <span class="more-info"> + <h3>LDAP Settings</h3> + <table class="form-table"> + <tr valign="top"> + <th scope="row">LDAP-Authentication</th> + <td> + <input type='radio' name='ldapOptionsAuth' id='authEnable' value='1' <?php echo $tChecked ?>/> <label for="authEnable">Enabled</label> + <input type='radio' name='ldapOptionsAuth' id='authDisable' value='0' <?php echo $fChecked ?>/> <label for="authDisable">Disabled</label> + <br/> + If this is disabled, then entire plugin will be disabled. Users will need to log in using WPMU user credentials, and will not be able to use LDAP credentials to access their accounts. + </td> + </tr> + <tr valign="top"> + <th scope="row">Enable SSL</th> + <td> + <input type='radio' name='ldapOptionsEnableSSL' id='sslOn' value='1' <?php echo $tEnableSSL ?>/> <label for="sslOn">Yes</label> + <input type='radio' name='ldapOptionsEnableSSL' id='sslOff' value='0' <?php echo $fEnableSSL ?>/> <label for="sslOff">No</label> + <br/> Select yes to connect over ldaps://, Select no to connect over ldap:// - </span> - </div> - - <div class="row" id="ldapOptionsServerAddr"> - <span class="description"> - <label for="serverAddr">LDAP Server Address:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerAddr .more-info');" /> - </span> - <span class="element"> - <input type='text' name='ldapOptionsServerAddr' id='serverAddr' value='$ldapServerAddr' style='width: 300px;' /> - </span> - <span class="more-info"> - The name or IP address of the LDAP server. The protocol should be left out.<br/> - (Ex. ldap.example.com) - </span> - </div> - - <div class="row" id="ldapOptionsServerPort"> - <span class="description"> - <label for="serverPort">LDAP Server Port:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerPort .more-info');" /> - </span> - <span class="element"> - <input type='text' name='ldapOptionsServerPort' id='serverPort' value='$ldapServerPort' style='width: 300px;' /> - </span> - <span class="more-info"> - Port Number of the LDAP server.<br/> - (LDAP: Linux=389, Windows=3268)<br/> - (LDAPS: Linux=686, Windows=3269) - </span> - </div> - - <div class="row" id="ldapOptionsServerOU"> - <span class="description"> - <label for="serverOU">Search DN:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerOU .more-info');" /> - </span> - <span class="element"> - <input type='text' name='ldapOptionsServerOU' id='serverOU' value='$ldapServerOU' style='width: 450px;' /> - </span> - <span class="more-info">The base DN in which to carry out LDAP searches.</span> - </div> - - <div class="row" id="ldapOptionsServerCN"> - <span class="description"> - <label for="serverCN">User DN for Searches:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerCN .more-info');" /> - </span> - <span class="element"> - <input type='text' name='ldapOptionsServerCN' id='serverCN' value='$ldapServerCN' style='width: 450px;' /> - </span> - <span class="more-info"> - Some systems do not allow anonymous searching for attributes, and so - this will set the account to use when connecting for searches. - </span> - </div> - - <div class="row" id="ldapOptionsServerPass"> - <span class="description"> - <label for='serverPass'>Password:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsServerPass .more-info');" /> - </span> - <span class="element"> - <input type='password' name='ldapOptionsServerPass' id='serverPass' value='$ldapServerPass' /> - </span> - - <span class="more-info">Password for the User DN above.</span> - </div> - - <div class="row" id="ldapOptionsLinuxWindows"> - <span class="description">Linux or Windows LDAP:</span> - <span class="element"> - <input type='radio' name='ldapOptionsLinuxWindows' id='linux' value='1' $tLinWin/> <label for="linux">Linux</label> - <input type='radio' name='ldapOptionsLinuxWindows' id='windows' value='0' $fLinWin/> <label for="windows">Windows</label> - </span> - </div> - </fieldset> - - <fieldset class="options"> - <legend>LDAP Plugin Settings</legend> - - <div class="row" id="ldapOptionsCreateAcct"> - <span class="description"> - Auto-Create WPMU Accounts? - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsCreateAcct .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsCreateAcct' id='createAcctYes' value='1' $tAcctChecked/> <label for="createAcctYes">Yes</label> - <input type='radio' name='ldapOptionsCreateAcct' id='createAcctNo' value='0' $fAcctChecked/> <label for="createAcctNo">No</label> - </span> - - <span class="more-info" id="more-info"> + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="serverAddr">Server Address</label></th> + <td> + <input type='text' name='ldapOptionsServerAddr' id='serverAddr' value='<?php echo $ldapServerAddr ?>' style='width: 300px;' /> + <br/> + The name or IP address of the LDAP server. The protocol should be left out. (Ex. ldap.example.com) + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="serverPort">LDAP Server Port</label></th> + <td> + <input type='text' name='ldapOptionsServerPort' id='serverPort' value='<?php echo $ldapServerPort ?>' style='width: 300px;' /> + <br/> + Port Number of the LDAP server. (LDAP: Linux=389, Windows=3268) (LDAPS: Linux=686, Windows=3269) + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="serverOU">Search DN</label></th> + <td> + <input type='text' name='ldapOptionsServerOU' id='serverOU' value='<?php echo $ldapServerOU; ?>' style='width: 450px;' /> + <br/> + The base DN in which to carry out LDAP searches. + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="serverCN">User DN for Searches</label></th> + <td> + <input type='text' name='ldapOptionsServerCN' id='serverCN' value='<?php echo $ldapServerCN; ?>' style='width: 450px;' /> + <br/> + Some systems do not allow anonymous searching for attributes, and so this will set the account to use when connecting for searches. + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for='serverPass'>Password</label></th> + <td> + <input type='password' name='ldapOptionsServerPass' id='serverPass' value='<?php echo $ldapServerPass; ?>' /> + <br/> + Password for the User DN above. + </td> + </tr> + <tr valign="top"> + <th scope="row">LDAP Type</th> + <td> + <input type='radio' name='ldapOptionsLinuxWindows' id='linux' value='1' <?php echo $tLinWin; ?>/> <label for="linux">Linux</label> + <input type='radio' name='ldapOptionsLinuxWindows' id='windows' value='0' <?php echo $fLinWin; ?>/> <label for="windows">Windows</label> + </td> + </tr> + <tr valign="top"> + <th scope="row">Auto-Create WPMU Accounts?</th> + <td> + <input type='radio' name='ldapOptionsCreateAcct' id='createAcctYes' value='1' <?php echo $tAcctChecked ?>/> <label for="createAcctYes">Yes</label> + <input type='radio' name='ldapOptionsCreateAcct' id='createAcctNo' value='0' <?php echo $fAcctChecked ?>/> <label for="createAcctNo">No</label> <p>If "Yes", this will automatically create a WPMU account for any user that successfully authenticates against the LDAP server. The WPMU user account will be named the same as the LDAP username. - <p>If "No", then a + </p><p>If "No", then a Site Admin must create a WPMU user account for the user to be able to log in. The WPMU user account must be named the same as the LDAP username for LDAP authentication to function. - </span> - </div> - - <div class="row" id="ldapOptionsCreateBlog"> - <span class="description"> - Auto-Create WPMU Blogs? - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsCreateBlog .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsCreateBlog' id='createBlogYes' value='1' $tBlogChecked/> <label for="createBlogYes">Yes</label> - <input type='radio' name='ldapOptionsCreateBlog' id='createBlogNo' value='0' $fBlogChecked/> <label for="createBlogNo">No</label> - </span> - - <span class="more-info" id="more-info"> - <p>If "Yes", this will automatically create a WPMU blog for any user - that successfully authenticates against the LDAP server. The blog will - be named the same as the LDAP username. - <p>If "No", then a - Site Admin must create a WPMU blog for the user to be able to - log in. - </span> - </div> - - - <div class="row" id="ldapOptionsDisableSignup"> - <span class="description"> - Disable Public Signup? - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsDisableSignup .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupYes' value='1' $tDisableSignup/> <label for="disableSignupYes">Yes</label> - <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupNo' value='0' $fDisableSignup/> <label for="disableSignupNo">No</label> - </span> - <span class="more-info"> - This overrides all actions that take place within wp-signup.php, - effectively disabling public signup. - </span> - </div> - - <div class="row" id="ldapOptionsCreateLocalUser"> - <span class="description"> - Allow creation of local user accounts? - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapOptionsCreateLocalUser .more-info');" /> - </span> - <span class="element"> - <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserYes' value='1' $tCreateLocalUser/> <label for="createLocalUserYes">Yes</label> - <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserNo' value='0' $fCreateLocalUser/> <label for="createLocalUserNo">No</label> - </span> - <span class="more-info"> + </p> + </td> + </tr> + <tr valign="top"> + <th scope="row">Auto-Create WPMU Blogs?</th> + <td> + <input type='radio' name='ldapOptionsCreateBlog' id='createBlogYes' value='1' <?php echo $tBlogChecked; ?>/> <label for="createBlogYes">Yes</label> + <input type='radio' name='ldapOptionsCreateBlog' id='createBlogNo' value='0' <?php echo $fBlogChecked; ?>/> <label for="createBlogNo">No</label> + <p> + If "Yes", this will automatically create a WPMU blog for any user that successfully authenticates against the LDAP server. The blog will be named the same as the LDAP username. + </p><p> + If "No", then a Site Admin must create a WPMU blog for the user to be able to log in. + </p> + </td> + </tr> + <tr valign="top"> + <th scope="row">Disable Public Signup?</th> + <td> + <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupYes' value='1' <?php echo $tDisableSignup; ?>/> <label for="disableSignupYes">Yes</label> + <input type='radio' name='ldapOptionsDisableSignup' id='disableSignupNo' value='0' <?php echo $fDisableSignup; ?>/> <label for="disableSignupNo">No</label> + <br/> + This overrides all actions that take place within wp-signup.php, effectively disabling public signup. + </td> + </tr> + <tr valign="top"> + <th scope="row">Create local users?</th> + <td> + <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserYes' value='1' <?php echo $tCreateLocalUser ?>/> <label for="createLocalUserYes">Yes</label> + <input type='radio' name='ldapOptionsCreateLocalUser' id='createLocalUserNo' value='0' <?php echo $fCreateLocalUser ?>/> <label for="createLocalUserNo">No</label> + <br/> This will either allow or disallow the creation of local accounts. - </span> - </div> - - <div class="row" id="ldapSignupMessage"> - <span class="description"> - <label for="ldapSignupMessage">Signup-Disabled Message:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapSignupMessage .more-info');" /> - </span> - <span class="element"> - <textarea name='ldapSignupMessage' id='ldapSignupMessage'>$ldapSignupMessage</textarea> - </span> - - <span class="more-info">This is an alternate HTML message that would be displayed in place of any actions at wp-signup.php.</span> - </div> - - <div class="row" id="ldapGetPasswordMessage"> - <span class="description"> - <label for="ldapGetPasswordMessage">Lost-Password Message:</label> - <img title="Click for more info" src="$moreInfoImgUrl" onclick="toggleShow('#ldapGetPasswordMessage .more-info');" /> - </span> - <span class="element"> - <textarea name='ldapGetPasswordMessage' id='ldapGetPasswordMessage'>$ldapGetPasswordMessage</textarea> - </span> - <span class="more-info"> + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="ldapSignupMessage">Signup-Disabled Message:</label></th> + <td> + <textarea name='ldapSignupMessage' id='ldapSignupMessage'><?php echo $ldapSignupMessage ?></textarea> + <br/> + This is an alternate HTML message that would be displayed in place of any actions at wp-signup.php. + </td> + </tr> + <tr valign="top"> + <th scope="row"><label for="ldapGetPasswordMessage">Lost-Password Message:</label></th> + <td> + <textarea name='ldapGetPasswordMessage' id='ldapGetPasswordMessage'><?php echo $ldapGetPasswordMessage ?></textarea> + <br/> This is the error message that would be displayed when an LDAP-account user submits "Lost Password" requests. - </span> - </div> - + </td> + </tr> + + </table> <p class="submit"><input type="submit" name="ldapOptionsSave" value="Save" /></p> - </fieldset> </form> - </div> -LdapForm; +</div> +<?php } /** Modified: trunk/ldap/public/ldap_auth.css =================================================================== --- trunk/ldap/public/ldap_auth.css 2008-07-18 15:51:49 UTC (rev 55) +++ trunk/ldap/public/ldap_auth.css 2008-07-18 19:49:52 UTC (rev 56) @@ -31,19 +31,18 @@ height: 50px; } #wpmuLdapAdminRequest { - margin: auto; - width: 90%; - padding: 5px; - text-align: center; font-size: 1.2em; - border: 1px solid #882828; font-weight: bold; - background-color: #ec4d4d; - margin-bottom: 15px; + background-color: #ec4d4d; + padding: 5px; + color: #e8e8e8; + margin-top: 10px; } #wpmuLdapAdminRequest p { margin: 0px; padding: 0px; font-size: 0.8em; } - +.ldapmeta { + color: red; +} Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-07-18 15:51:49 UTC (rev 55) +++ trunk/ldap_auth.php 2008-07-18 19:49:52 UTC (rev 56) @@ -81,7 +81,7 @@ } // Try for local login - if (!$ldap_login) { + if ($ldap_login != true || $ldap_login != 'true') { if ( !$user || ($user->user_login != $username) ) { do_action( 'wp_login_failed', $username ); return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.')); @@ -90,7 +90,7 @@ if ( !wp_check_password($password, $user->user_pass, $user->ID) ) { do_action( 'wp_login_failed', $username ); return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.')); - } + } return new WP_User($user->ID); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-07-18 15:51:51
|
Revision: 55 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=55&view=rev Author: axelseaa Date: 2008-07-18 15:51:49 +0000 (Fri, 18 Jul 2008) Log Message: ----------- fixed issue with retrieve password form, also implemented new function/hook that is pending approval from the WP team Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-17 14:48:15 UTC (rev 54) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-18 15:51:49 UTC (rev 55) @@ -442,63 +442,62 @@ } } -// we have no desire to manage or manipulate the LDAP password, so the "lost -// password" action doesn't make sense for LDAP accounts; so work around it -add_action('retrieve_password', 'ldapRetrievePassword'); +/** We have no desire to manage or manipulate the LDAP password, so the "lost + * password" action doesn't make sense for LDAP accounts; so work around it + */ function ldapRetrievePassword($userName) { - global $errors; - - $login = get_userdatabylogin($userName); + $login = get_userdatabylogin($userName); $ldap_login = get_usermeta($login->ID, 'ldap_login'); - if ($ldap_login == true) { - // get the configurable error message: - $getPwdMessage = get_site_option('ldapGetPasswordMessage'); + if ($ldap_login == true) { + // get the configurable error message: + $getPwdMessage = get_site_option('ldapGetPasswordMessage'); - $errors['nonewpassword'] = __("<strong>ERROR</strong>: $getPwdMessage"); - login_header(__('Lost Password')); + $pwderror = __("<strong>ERROR</strong>: $getPwdMessage"); + login_header(__('Lost Password')); - // HACK: Just shows a cut-n-paste of the login form as a workaround, since actions do not allow us to cease execution (e.g., by returning false), so need to display the form with the error message + // HACK: Just shows a cut-n-paste of the login form as a workaround, since actions do not allow us to cease execution (e.g., by returning false), so need to display the form with the error message ?> -<form name="lostpasswordform" id="lostpasswordform" action="wp-login.php?action=lostpassword" method="post"> - <p> - <label><?php _e('Username:') ?><br /> - <input type="text" name="user_login" id="user_login" class="input" value="<?php echo -attribute_escape(stripslashes($_POST['user_login'])); ?>" size="20" tabindex="10" /></label> - </p> - <p> - <label><?php _e('E-mail:') ?><br /> - <input type="text" name="user_email" id="user_email" class="input" value="<?php echo -attribute_escape(stripslashes($_POST['user_email'])); ?>" size="25" tabindex="20" /></label> - </p> -<?php do_action('lostpassword_form'); ?> - <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Get New Password »'); ?>" tabindex="100" /></p> -</form> -</div> - +<div id="login_error"><?php echo $pwderror ?></div> <ul> <?php if (get_option('users_can_register')) : ?> - <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> - <li><a href="<?php bloginfo('wpurl'); ?>/signup/"><?php _e('Register') ?></a></li> - <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); + <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> + <li><a href="<?php bloginfo('wpurl'); ?>/signup/"><?php _e('Register') ?></a></li> + <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), +get_bloginfo('title')); ?></a></li> <?php else : ?> - <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); + <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), +get_bloginfo('title')); ?></a></li> - <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> + <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> <?php endif; ?> </ul> - </body> </html> <?php - die(); - } else { - return true; - } + die(); + } else { + return true; + } } +add_action('retrieve_password', 'ldapRetrievePassword'); +/** + * New proposed solution for retrieve password - pending patch implementation by WP team. + */ +function ldapRetrievePasswordError($userID,$pass_error) { + #$login = get_userdatabylogin($userName); + #$ldap_login = get_usermeta($login->ID, 'ldap_login'); + $ldap_login = get_usermeta($userID, 'ldap_login'); + if ($ldap_login == true) { + // get the configurable error message: + $pass_error = get_site_option('ldapGetPasswordMessage'); + } +} +#add_action('retrieve_password_error', 'ldapRetrievePasswordError',10,2); + /** * Returns false if LDAP authentication is turned on, the current user is a site * admin and the use being currently edited is a site admin. Essentially is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-07-17 14:49:05
|
Revision: 54 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=54&view=rev Author: axelseaa Date: 2008-07-17 14:48:15 +0000 (Thu, 17 Jul 2008) Log Message: ----------- added function to admin page to set ldap_login meta values for all users - this will break local users! admin local users is not effected Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap_admin.functions.php Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-06 23:50:35 UTC (rev 53) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-07-17 14:48:15 UTC (rev 54) @@ -38,6 +38,10 @@ update_site_option('ldapGetPasswordMessage', stripslashes($_POST['ldapGetPasswordMessage'])); echo "<div id='message' class='updated fade'><p>Saved Options!</p></div>"; + } else if ($_POST['ldapFixMeta']) { + wpmuLdapFixMeta(); + + echo "<div id='message' class='updated fade'><p>All users ldap_auth meta values updated!</p></div>"; } $defaultSignupMessage = <<<NoSignupMsg @@ -181,7 +185,25 @@ accounts. It is recommended that you still maintain a local <strong>admin</strong> account to allow access if the LDAP server is unavailable. </p> + <form method="post" id="ldap_fix_meta"> + <fieldset class="options"> + <div class="row"> + <span class="description"> + Update ldap_login meta + </span> + <span class="element"> + <input type="submit" name="ldapFixMeta" value="Fix" /> + </span> + <span class="more-info"> + Clicking on the button will update ALL blog users except admin to be set with the ldap_login meta value. + If you have local users, this will also change them. This is only needed for those users upgrading from the + 1.3 series of wordpress. + </span> + </div> + </fieldset> + </form> + <form method="post" id="ldap_auth_options"> <fieldset class="options"> @@ -541,4 +563,17 @@ wp_mail($user_email, sprintf(__('[%s] Blogging Account Created'), get_option('blogname')), $message); } +/** + * Updates all user meta values to make sure ldap_auth is enabled and set to true. This will break local + * user accounts. The admin user is not touched. + */ +function wpmuLdapFixMeta() { + global $wpdb; + $users = $wpdb->get_results("SELECT ID from $wpdb->users WHERE ID > 1"); + foreach ($users as $user) { + update_usermeta( $user->ID, 'ldap_login', 'true' ); + } +} + + ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-07-06 23:50:39
|
Revision: 53 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=53&view=rev Author: axelseaa Date: 2008-07-06 16:50:35 -0700 (Sun, 06 Jul 2008) Log Message: ----------- locking in 1.5.0 release Added Paths: ----------- tags/wpmu-ldap_1.5.0/ Copied: tags/wpmu-ldap_1.5.0 (from rev 52, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-30 22:39:25
|
Revision: 52 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=52&view=rev Author: axelseaa Date: 2008-06-30 15:39:21 -0700 (Mon, 30 Jun 2008) Log Message: ----------- fix for bug #2003216 - has_cap() error still appears in a few places, finished updating to return new wp_user or wp_error object Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2008-06-30 22:37:53 UTC (rev 51) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2008-06-30 22:39:21 UTC (rev 52) @@ -19,8 +19,7 @@ $user_id = wpmu_create_user( $newUserName, $sPassword, $ldapUserData[LDAP_INDEX_EMAIL] ); if ( $user_id === false ) { - $error = __('<strong>Error</strong>: Account creation failed - contact your administrator.'); - return false; + return new WP_Error('ldapcreate_failed', __('<strong>ERROR</strong>: Account creation from LDAP failed.')); } //Update their first and last name from ldap @@ -50,15 +49,15 @@ $blog_id = wpmu_create_blog($newdomain, $path, $newUserName . "'s blog", $user_id, $meta); if ( is_a($blog_id, "WP_Error") ) { - $error = __('<strong>Error</strong>: Blog creation failed - contact your administrator.'); - return false; + return new WP_Error('blogcreate_failed', __('<strong>ERROR</strong>: Blog creation from LDAP failed.')); } do_action('wpmu_activate_blog', $blog_id, $user_id, $newUserPassword, $newUserName . "'s blog", $meta); } //Must recreated the login object for our shiny NEW users. - return get_userdatabylogin($newUserName); + #return get_userdatabylogin($newUserName); + return new WP_User($user_id); } @@ -85,7 +84,6 @@ $errors->add('unknown_error',__('<strong>ERROR</strong>: Unknown error in LDAP Authentication.')); return array('result' => false,'errors' => $errors); } - } /** @@ -109,25 +107,17 @@ // Make the WP users automatically if we're configured to do so if ($ldapCreateAcct ) { - $loginObj = wpmuLdapCreateWPUserFromLdap($loginUserName, $loginPassword, $userDataArray); - // If the account creation failed, the login process needs to fail. - if ( $loginObj === false ) { - echo "Failed!"; - return false; - } - //Setup redirection to user's home directory. if (!strpos($_REQUEST['redirect_to'], $loginUserName)) { $_REQUEST['redirect_to'] = $loginUserName . "/" . $_REQUEST['redirect_to']; } - - return new WP_User($loginObj->ID); + + return wpmuLdapCreateWPUserFromLdap($loginUserName, $loginPassword, $userDataArray); } // but if not configured to create 'em, exit with an error else { - $error = __('<strong>Error</strong>: A blogging account does not exist - contact your administrator.'); - return false; + return new WP_Error('account_noexist', __('<strong>ERROR</strong>: A blogging account does not exist - contact your administrator.')); } } @@ -137,16 +127,14 @@ // At this point we must have a login object, but just in case something went wrong if (!$loginObj) { - $error = __('<strong>Error</strong>: Unknown error in LDAP Authentication.'); - return false; + return new WP_Error('unknown_error', __('<strong>ERROR</strong>: Unknown error in LDAP Authentication.')); } // Since the login was successful, lets set a meta object to know we are using ldap $ldapMeta = get_usermeta($loginObj->ID,'ldap_login'); if ($ldapMeta != 'true') { if (!update_usermeta($loginObj->ID, 'ldap_login', 'true')) { - $error = __('<strong>Error</strong>: Error updating user meta information.'); - return false; + return new WP_Error('update_usermeta', __('<strong>ERROR</strong>: Error updating user meta information.')); } } @@ -156,8 +144,7 @@ $details = get_blog_details( $primary_blog ); if( is_object( $details ) ) { if( $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - $error = __('<strong>Error</strong>: Blog suspended.'); - return false; + return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-30 22:38:05
|
Revision: 51 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=51&view=rev Author: axelseaa Date: 2008-06-30 15:37:53 -0700 (Mon, 30 Jun 2008) Log Message: ----------- formatting changes Modified Paths: -------------- trunk/ldap_auth.php Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-06-30 20:32:54 UTC (rev 50) +++ trunk/ldap_auth.php 2008-06-30 22:37:53 UTC (rev 51) @@ -3,8 +3,14 @@ Plugin Name: LDAP Authentication Plug-in Plugin URI: http://sourceforge.net/projects/wpmu-ldap Description: A plugin to override the core Wordpress MU authentication method (for non-site admins) so as to use an LDAP server for authentication. -Version: 1.3.0 -Author: Alistair Young (http://www.weblogs.uhi.ac.uk/sm00ay/), Patrick Cavit (http://patcavit.com), Hugo Salgado (http://hugo.vulcano.cl), Alex Barker (http://www.callutheran.edu), Dexter Arver, Sean Wedig (http://www.thecodelife.net), Aaron Axelsen +Version: 1.5.1 +Author: Alistair Young (http://www.weblogs.uhi.ac.uk/sm00ay/), + Patrick Cavit (http://patcavit.com), + Hugo Salgado (http://hugo.vulcano.cl), + Alex Barker (http://www.callutheran.edu), + Dexter Arver, + Sean Wedig (http://www.thecodelife.net), + Aaron Axelsen (http://www.frozenpc.net) */ // Includes @@ -20,7 +26,6 @@ // *** End Admin Config Functions *** // - // *** Begin User Auth Functions *** // // disable public signup if configured to do so if (get_site_option("ldapDisableSignup") ) { @@ -60,35 +65,35 @@ $ldap_login = get_usermeta($user->ID,'ldap_login'); - if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $user->ID, "primary_blog" ) ) ) { - $details = get_blog_details( $primary_blog ); - if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); - } - } else { - // If user does not have a primary blog, set them as a subscriber to blog 1 - add_user_to_blog('1',$user->ID,'subscriber'); - } + if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $user->ID, "primary_blog" ) ) ) { + $details = get_blog_details( $primary_blog ); + if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { + return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); + } + } else { + // If user does not have a primary blog, set them as a subscriber to blog 1 + add_user_to_blog('1',$user->ID,'subscriber'); + } - //Setup redirection to users home directory. - if (!strpos($_REQUEST['redirect_to'], $username)) { - $_REQUEST['redirect_to'] = $username . "/" . $_REQUEST['redirect_to']; - } + //Setup redirection to users home directory. + if (!strpos($_REQUEST['redirect_to'], $username)) { + $_REQUEST['redirect_to'] = $username . "/" . $_REQUEST['redirect_to']; + } - // Try for local login - if (!$ldap_login) { - if ( !$user || ($user->user_login != $username) ) { - do_action( 'wp_login_failed', $username ); - return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.')); - } + // Try for local login + if (!$ldap_login) { + if ( !$user || ($user->user_login != $username) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.')); + } - if ( !wp_check_password($password, $user->user_pass, $user->ID) ) { - do_action( 'wp_login_failed', $username ); - return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.')); - } + if ( !wp_check_password($password, $user->user_pass, $user->ID) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.')); + } - return new WP_User($user->ID); - } + return new WP_User($user->ID); + } } // Authenticate via LDAP, potentially creating a WP user @@ -100,7 +105,5 @@ return $ldapauthresult['errors']; } } - } - ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-30 20:32:59
|
Revision: 50 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=50&view=rev Author: axelseaa Date: 2008-06-30 13:32:54 -0700 (Mon, 30 Jun 2008) Log Message: ----------- fixed php warning on users page Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-06-26 04:32:51 UTC (rev 49) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-06-30 20:32:54 UTC (rev 50) @@ -503,6 +503,13 @@ } /** + * Disable the built in add user form on the users page. + */ +function wpmuLdapDisableShowUser() { + return false; +} + +/** * Overriding of the new user notification, so that users are not confused by * email messages with passwords. * Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-06-26 04:32:51 UTC (rev 49) +++ trunk/ldap_auth.php 2008-06-30 20:32:54 UTC (rev 50) @@ -39,7 +39,7 @@ add_filter('show_password_fields', 'wpmuLdapDisableLdapPassword'); // disable default add user box - add_filter('show_adduser_fields', false); + add_filter('show_adduser_fields', 'wpmuLdapDisableShowUser'); function wp_authenticate($username,$password) { // make sure we always use lowercase usernames This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-26 04:33:00
|
Revision: 49 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=49&view=rev Author: axelseaa Date: 2008-06-25 21:32:51 -0700 (Wed, 25 Jun 2008) Log Message: ----------- fixed potential naming conflict Modified Paths: -------------- trunk/ldap_auth.php Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-06-26 04:26:45 UTC (rev 48) +++ trunk/ldap_auth.php 2008-06-26 04:32:51 UTC (rev 49) @@ -92,12 +92,12 @@ } // Authenticate via LDAP, potentially creating a WP user - $ldapauth = wpmuLdapAuthenticate($ldapString, $username, $password); + $ldapauthresult = wpmuLdapAuthenticate($ldapString, $username, $password); - if ($ldapauth['result']) { - return wpmuLdapProcess($user, $username, $password, $ldapauth['userdata']); + if ($ldapauthresult['result']) { + return wpmuLdapProcess($user, $username, $password, $ldapauthresult['userdata']); } else { - return $ldapauth['errors']; + return $ldapauthresult['errors']; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-26 04:26:49
|
Revision: 48 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=48&view=rev Author: axelseaa Date: 2008-06-25 21:26:45 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Second attempt at wpmu 1.5.1 changes: - Remove wp_setcookie function, no longer needed - Removed experimental wp_munge hooks, no longer needed - Revamped logic for local users - removed unneeded bits - Fixed major logic flaw with login in the first attempt Modified Paths: -------------- trunk/ldap/lib/wpmu_ldap.functions.php trunk/ldap/lib/wpmu_ldap_admin.functions.php trunk/ldap_auth.php Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2008-06-17 17:57:46 UTC (rev 47) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2008-06-26 04:26:45 UTC (rev 48) @@ -63,7 +63,7 @@ function wpmuLdapAuthenticate($ldapString, $loginUserName, $loginPassword) { - global $error; + $errors = new WP_Error; $server = new LDAP_ro($ldapString); $server->DebugOff(); @@ -71,20 +71,19 @@ $userDataArray = null; $result = $server->Authenticate ($loginUserName, $loginPassword, $userDataArray); if ($result == LDAP_OK) { - return array(true,$userDataArray); + return array('result' => true,'userdata' => $userDataArray); } // handle both at once, for security - else if ( ($result == LDAP_ERROR_USER_NOT_FOUND) || ($result == LDAP_ERROR_WRONG_PASSWORD) ) { - $error = __('<strong>Error</strong>: Wrong username / password combination.'); - $pwd = ''; - return array(false); + else if ( ($result == LDAP_ERROR_USER_NOT_FOUND || $result == LDAP_ERROR_WRONG_PASSWORD) ) { + $errors->add('invalid_userpass',__('<strong>ERROR</strong>: Wrong username / password combination.')); + return array('result' => false,'errors' => $errors); } // the trickle-through catch-all else { - $error = __('<strong>Error</strong>: Unknown error in LDAP Authentication.'); - return array(false); + $errors->add('unknown_error',__('<strong>ERROR</strong>: Unknown error in LDAP Authentication.')); + return array('result' => false,'errors' => $errors); } } Modified: trunk/ldap/lib/wpmu_ldap_admin.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-06-17 17:57:46 UTC (rev 47) +++ trunk/ldap/lib/wpmu_ldap_admin.functions.php 2008-06-26 04:26:45 UTC (rev 48) @@ -503,30 +503,6 @@ } /** -* *** NOT PRODUCTION *** -* -* This function is used to munge the username/password using the wp_munge hook which is currently not implemented. -* See http://trac.wordpress.com/ticket/5400 for more information -* -* This hack is currently only necessary if you wish to use the admin-ssl plugin with wordpress -* -* @param string $username -* @param string $password -*/ -function wpmuLdapMunge(&$username,&$password) { - $username = strtolower($username); - $username = sanitize_user($username); - $ldapCookieMarker = get_site_option("ldapCookieMarker"); - $login = get_userdatabylogin($username); - $ldapMeta = get_usermeta($login->ID,'ldap_login'); - - if ($ldapMeta == 'true') { - // This handles all LDAP-authenticated users - $password = $username.$ldapCookieMarker; - } -} - -/** * Overriding of the new user notification, so that users are not confused by * email messages with passwords. * Modified: trunk/ldap_auth.php =================================================================== --- trunk/ldap_auth.php 2008-06-17 17:57:46 UTC (rev 47) +++ trunk/ldap_auth.php 2008-06-26 04:26:45 UTC (rev 48) @@ -17,9 +17,7 @@ add_action('admin_head', 'ldapShowOptionsCss'); add_action('admin_menu', 'ldap_addmenu'); add_action('admin_menu', 'ldap_addmenuuser'); -add_action('wp_munge','wpmuLdapMunge',10,2); - // *** End Admin Config Functions *** // @@ -54,123 +52,55 @@ // setup ldap string $ldapString = wpmuSetupLdapString(); - if($ldapAuth && !$ldapCookieMarker) { - update_site_option("ldapCookieMarker", "LDAP"); - $ldapCookieMarker = get_site_option("ldapCookieMarker"); - } - // try finding a WP account for this user name - $login = get_userdatabylogin($username); + $user = get_userdatabylogin($username); // if username exists, lets check and see if they are already logged in - if ($login != false) { + if ($user != false) { - $ldap_login = get_usermeta($login->ID,'ldap_login'); - if ($ldap_login == 'true') { - // If already_md5 is TRUE, then we're getting the user/password from the - // cookie instead of POST. As we don't want to store LDAP passwords in any - // form, we've already replaced the password with the hashed username and - // LDAP_COOKIE_MARKER - if ($already_md5 && ($password == md5(md5($username.$ldapCookieMarker))) ) { - return true; - } - } else { - if( is_site_admin( $username ) ) { - unset( $login ); - $userdetails = get_userdatabylogin( $username ); - $login->user_login = $username; - $login->user_pass = $userdetails->user_pass; - } else { - $admins = get_admin_users_for_domain(); - reset( $admins ); - foreach( $admins as $admin ) { - if( $admin[ 'user_login' ] == $username ) { - unset( $login ); - $login->user_login = $username; - $login->user_pass = $admin[ 'user_pass' ]; - } - } - } - if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $login->ID, "primary_blog" ) ) ) { + $ldap_login = get_usermeta($user->ID,'ldap_login'); + + if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $user->ID, "primary_blog" ) ) ) { $details = get_blog_details( $primary_blog ); if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - $error = __('<strong>Error</strong>: Blog suspended.'); - return false; + return new WP_Error('blog_suspended', __('<strong>ERROR</strong>: Blog suspended.')); } } else { // If user does not have a primary blog, set them as a subscriber to blog 1 - add_user_to_blog('1',$loginObj->ID,'subscriber'); + add_user_to_blog('1',$user->ID,'subscriber'); } - //Setup redirection to users home directory. if (!strpos($_REQUEST['redirect_to'], $username)) { $_REQUEST['redirect_to'] = $username . "/" . $_REQUEST['redirect_to']; } - #if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || - if ( ($login->user_login == $username ) || - ($login->user_login == $username && $login->user_pass == md5($password))) { - return new WP_User($login->ID); - } else { - $error = __('<strong>Error</strong>: Incorrect password.'); - $pwd = ''; - return false; + // Try for local login + if (!$ldap_login) { + if ( !$user || ($user->user_login != $username) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.')); + } + + if ( !wp_check_password($password, $user->user_pass, $user->ID) ) { + do_action( 'wp_login_failed', $username ); + return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.')); + } + + return new WP_User($user->ID); } - } } - // No cookie, so authenticate them via LDAP, potentially creating a WP user - $result = wpmuLdapAuthenticate($ldapString, $username, $password); - if ($result[0]) { - return wpmuLdapProcess($login, $username, $password, $result[1]); + // Authenticate via LDAP, potentially creating a WP user + $ldapauth = wpmuLdapAuthenticate($ldapString, $username, $password); + + if ($ldapauth['result']) { + return wpmuLdapProcess($user, $username, $password, $ldapauth['userdata']); } else { - #if ( ($login->user_login == $username && $login->user_pass == md5($password)) ) { - if ( ($login->user_login == $username ) ) { - return new WP_User($login->ID); - } + return $ldapauth['errors']; } } - /** - * HOPEFULLY THIS WILL BE REMOVED IN FUTURE VERSIONS - * Overridden version of WPMU's wp_setcookie method to allow for different - * hashing of LDAP-authenticated passwords stored in cookies. This - * different hashing will only apply to non-site admins, or to everyone if - * LDAP authentication is disabled. - */ - if ( !function_exists('wp_setcookie') ) : - function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember=false) { - $ldapAuth = get_site_option("ldapAuth"); - - if ($ldapAuth) { - $ldapCookieMarker = get_site_option("ldapCookieMarker"); - $login = get_userdatabylogin($username); - $ldapMeta = get_usermeta($login->ID,'ldap_login'); - - if ($ldapMeta == 'true') { - // This handles all LDAP-authenticated users - $password = $username.$ldapCookieMarker; - } - } - - if(!$already_md5) { - // Basically this will check admin or users when ldap is disabled. - $password = md5( md5($password) ); // Double hash the password in the cookie. - } - - // From Here Down the File is Stock Form pluggable.php after #125: login-cookie-01.patch - if ( $remember ) - $expire = time() + 31536000; - else - $expire = 0; - - global $base; - setcookie(USER_COOKIE, $username, $expire, $base, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, $password, $expire, $base, COOKIE_DOMAIN); - } - // *** End User Auth Functions *** // - endif; } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axe...@us...> - 2008-06-17 17:58:22
|
Revision: 47 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=47&view=rev Author: axelseaa Date: 2008-06-17 10:57:46 -0700 (Tue, 17 Jun 2008) Log Message: ----------- no longer needed Removed Paths: ------------- trunk/pluggable.php Deleted: trunk/pluggable.php =================================================================== --- trunk/pluggable.php 2008-06-17 17:53:54 UTC (rev 46) +++ trunk/pluggable.php 2008-06-17 17:57:46 UTC (rev 47) @@ -1,163 +0,0 @@ -<?php - -if ( !function_exists('wp_login') ) : -function wp_login($username, $password, $already_md5 = false) { - global $wpdb, $error, $current_user; - - $username = strtolower($username); - - if ( !$username ) - return false; - - if ( !$password ) { - $error = __('<strong>Error</strong>: The password field is empty.'); - return false; - } - - if ($current_user->data->user_login == $username) - return true; - - $login = get_userdatabylogin($username); - //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'"); - - if (!$login) { - if( is_site_admin( $username ) ) { - unset( $login ); - $userdetails = get_userdatabylogin( $username ); - $login->user_login = $username; - $login->user_pass = $userdetails->user_pass; - } else { - $admins = get_admin_users_for_domain(); - reset( $admins ); - while( list( $key, $val ) = each( $admins ) ) - { - if( $val[ 'user_login' ] == $username ) { - unset( $login ); - $login->user_login = $username; - $login->user_pass = $val[ 'user_pass' ]; - } - } - } - } - if (!$login) { - $error = __('<strong>Error</strong>: Wrong username.'); - return false; - } else { - if( is_site_admin( $username ) == false && ( $primary_blog = get_usermeta( $login->ID, "primary_blog" ) ) ) { - $details = get_blog_details( $primary_blog ); - if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) { - $error = __('<strong>Error</strong>: Blog suspended.'); - return false; - } - } - // If the password is already_md5, it has been double hashed. - // Otherwise, it is plain text. - if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) { - return true; - } else { - $error = __('<strong>Error</strong>: Incorrect password.'); - $pwd = ''; - return false; - } - } -} -endif; - -if ( !function_exists('get_userdata') ) : -function get_userdata( $user_id ) { - global $wpdb, $cache_userdata, $wpmuBaseTablePrefix; - $user_id = (int) $user_id; - if ( $user_id == 0 ) - return false; - - $user = wp_cache_get($user_id, 'users'); - $user_level = $wpmuBaseTablePrefix . $wpdb->blogid . '_user_level'; - if ( $user && is_site_admin( $user->user_login ) ) { - $user->$user_level = 10; - $user->user_level = 10; - $cap_key = $wpdb->prefix . 'capabilities'; - $user->{$cap_key} = array( 'administrator' => '1' ); - return $user; - } elseif ( $user ) { - return $user; - } - - if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$user_id'") ) - return false; - - $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' /* pluggable get_userdata */"); - - if ($metavalues) { - foreach ( $metavalues as $meta ) { - @ $value = unserialize($meta->meta_value); - if ($value === FALSE) - $value = $meta->meta_value; - $user->{$meta->meta_key} = $value; - - // We need to set user_level from meta, not row - if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) - $user->user_level = $meta->meta_value; - } // end foreach - } //end if - - if( is_site_admin( $user->user_login ) == true ) { - $user->user_level = 10; - $cap_key = $wpdb->prefix . 'capabilities'; - $user->{$cap_key} = array( 'administrator' => '1' ); - } - - wp_cache_add($user_id, $user, 'users'); - wp_cache_add($user->user_login, $user, 'userlogins'); - - return $user; -} -endif; - -if ( !function_exists('get_userdatabylogin') ) : -function get_userdatabylogin($user_login) { - global $wpdb; - $user_login = sanitize_user( $user_login ); - - if ( empty( $user_login ) ) - return false; - - $userdata = wp_cache_get($user_login, 'userlogins'); - if( $userdata && is_site_admin( $user_login ) == true ) { - $userdata->user_level = 10; - $cap_key = $wpdb->prefix . 'capabilities'; - $userdata->{$cap_key} = array( 'administrator' => '1' ); - return $userdata; - } elseif( $userdata ) - return $userdata; - - if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) - return false; - - $metavalues = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user->ID'"); - - if ($metavalues) { - foreach ( $metavalues as $meta ) { - @ $value = unserialize($meta->meta_value); - if ($value === FALSE) - $value = $meta->meta_value; - $user->{$meta->meta_key} = $value; - - // We need to set user_level from meta, not row - if ( $wpdb->prefix . 'user_level' == $meta->meta_key ) - $user->user_level = $meta->meta_value; - } - } - if( is_site_admin( $user_login ) == true ) { - $user->user_level = 10; - $cap_key = $wpdb->prefix . 'capabilities'; - $user->{$cap_key} = array( 'administrator' => '1' ); - } - - wp_cache_add($user->ID, $user, 'users'); - wp_cache_add($user->user_login, $user, 'userlogins'); - - return $user; - -} -endif; -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |