Viewing 6 replies - 1 through 6 (of 6 total)
  • I would love to see the changes you’re making. Can you post a link to them?

    Thread Starter pribis

    (@pribis)

    Here is the patch info. As I remember a couple of functions needed to be changed due to deprecation errors. I also changed it to allow the user’s un and pw to be used to get need info. I didn’t want to allow anonymous logins to ldap nor did I want to use the admin un/pw (I thought I told diff to ignore space changes, but I guess not, sorry about that):

    brian@bxcp1u:~/projects/work/wp-plugins/patches$ less wpmuldap.patch
    diff -x .svn -ruN new/wpmuldap/ldap_auth.php wpmuldap/trunk/ldap_auth.php
    --- new/wpmuldap/ldap_auth.php  2012-09-28 12:43:16.000000000 -0400
    +++ wpmuldap/trunk/ldap_auth.php        2012-11-02 14:39:35.000000000 -0400
    @@ -24,7 +24,7 @@
     add_action('admin_menu', 'wpmuRemoveAddNewMenu');
     add_action('network_admin_menu', 'wpmuRemoveAddNewMenu');
    
     // perform these filters, actions, and WP function overrides only if LDAP-
     //  authentication is enabled; this is to cut down on parsing of this code when
    @@ -50,8 +50,10 @@
            require_once("lib/wpmu_ldap.functions.php");
    
            // Authentication filters
    -       add_action('authenticate', 'wpmuLdapUsernamePasswordAuthenticate', 25, 3);
    +    add_action('authenticate', 'wpmuLdapUsernamePasswordAuthenticate', 25, 3);
            add_filter('wp_authenticate_user', 'wpmuLdapCheckLdapMeta'); //disabled local login if ldap meta flag is set
    +
    +
            if (get_site_option('ldapSSOEnabled')) {
                    add_action('authenticate', 'wpmuLdapSSOAuthenticate', 40, 3);
                    add_filter('login_url', 'wpmuLdapSSODisableReauth'); //removes reauth from login URL
    diff -x .svn -ruN new/wpmuldap/lib/ldap_core.php wpmuldap/trunk/lib/ldap_core.php
    --- new/wpmuldap/lib/ldap_core.php      2012-09-28 12:43:16.000000000 -0400
    +++ wpmuldap/trunk/lib/ldap_core.php    2012-11-05 12:30:31.000000000 -0500
    @@ -74,19 +74,26 @@
                    return $return;
            }
    
    -       function Bind() {
    +       function Bind($un="", $pw="") {
                    $this->error_no = 0;
                    $this->error_txt = "Success";
                    $return = false;
                    $this->dn_passwd = stripslashes($this->dn_passwd);
    +        if(!$this->dn_passwd && $pw != "")
    +            $this->dn_passwd = $pw;
    +
    +        if($un != ""){
    +            $this->search_dn = "uid=$un,".$this->search_dn;
    +        }
    +
                    if ($this->connection_handle) {
                            if ($this->debug) {
    -                               if (ldap_bind ($this->connection_handle, $this->dn, $this->dn_passwd)) {
    +                               if (ldap_bind ($this->connection_handle, $this->search_dn, $this->dn_passwd)) {
                                            $return = true;
                                    }
                            }
                            else {
    -                               if (@ldap_bind ($this->connection_handle, $this->dn, $this->dn_passwd))
    +                               if (@ldap_bind ($this->connection_handle, $this->search_dn, $this->dn_passwd))
                                    $return = true;
                            }
                    }
    @@ -99,7 +106,10 @@
                    return $return;
            }
    
    -       function Dock() {
    +    /*
    +      Leave un and pw blank to anonymously bind
    +    */
    +       function Dock($un="", $pw="") {
                    // First, connect to the LDAP server
                    $result = $this->Connect();
                    if (!$result) {
    @@ -108,7 +118,7 @@
                    }
    
                    // Now bind as the user with enough rights to browse the "cn" attribute
    -               if (!$this->Bind()) {
    +               if (!$this->Bind($un, $pw)) {
                            $this->LogError();
                            return false;
                    }
    @@ -150,7 +160,8 @@
            function Search() {
                    if ($this->connection_handle) {
                            if ($this->debug) {
    -                               $this->search_result = ldap_search ($this->connection_handle, $this->search_dn, $this->search_string, $this->attributes_to_get);
    +
    +                               $this->search_result = ldap_search($this->connection_handle, $this->search_dn, $this->search_string, $this->attributes_to_get);
                                    $this->info = ldap_get_entries ($this->connection_handle, $this->search_result);
                            }
                            else {
    @@ -187,9 +198,9 @@
                    if ($type == LDAP_INDEX_NAME)                   return $this->info[0][$givenname][0]." ".$this->info[0][$sn][0];
                    if ($type == LDAP_INDEX_GIVEN_NAME)             return $this->info[0][$givenname][0];
                    if ($type == LDAP_INDEX_SURNAME)                return $this->info[0][$sn][0];
    -               if ($type == LDAP_INDEX_PHONE)                  return $this->info[0][$phone];
    +               //if ($type == LDAP_INDEX_PHONE)                        return $this->info[0][$phone];
                    if ($type == LDAP_INDEX_HOMEDIR)                return $this->info[0][$homedir][0];
    -               if ($type == LDAP_INDEX_MEMBER)                 return $this->info[0][$member];
    +               //if ($type == LDAP_INDEX_MEMBER)               return $this->info[0][$member];
                    if ($type == LDAP_INDEX_MACADDRESS)             return $this->info[0][$macaddress];
                    // When dealing with "uniqueMember", LDAP actually returns it as "member" - they're synonyms
                    if ($type == LDAP_INDEX_UNIQUE_MEMBER)          return $this->info[0][$member];
    diff -x .svn -ruN new/wpmuldap/lib/ldap_ro.php wpmuldap/trunk/lib/ldap_ro.php
    --- new/wpmuldap/lib/ldap_ro.php        2012-09-28 12:43:16.000000000 -0400
    +++ wpmuldap/trunk/lib/ldap_ro.php      2012-11-02 08:33:20.000000000 -0400
    @@ -24,7 +24,7 @@
     class LDAP_ro extends LDAP {
            function Authenticate ($in_username, $in_passwd, &$user_data) {
                    // First, connect to the LDAP server
    -               if(!$this->Dock()) {
    +               if(!$this->Dock($in_username, $in_passwd)) {
                            return LDAP_ERROR_CONNECTION;
                    }
    
    diff -x .svn -ruN new/wpmuldap/lib/wpmu_ldap.functions.php wpmuldap/trunk/lib/wpmu_ldap.functions.php
    --- new/wpmuldap/lib/wpmu_ldap.functions.php    2012-09-28 12:43:16.000000000 -0400
    +++ wpmuldap/trunk/lib/wpmu_ldap.functions.php  2012-11-02 14:38:03.000000000 -0400
    @@ -13,7 +13,7 @@
            global $base, $error, $wpdb, $current_site;
    
            // Extract Inputs
    -        extract($opts);
    +    extract($opts);
            if (!isset($newUserName))       $newUserName = '';
            if (!isset($newUserPassword))   $newUserPassword = '';
            if (!isset($ldapUserData))      $ldapUserData = false;
    @@ -24,11 +24,11 @@
                    return new WP_Error('ldapcreate_emailempty', sprintf(__('<strong>ERROR</strong>: <strong>%s</strong> does not have an email address associated with the ldap record.  All wordpress accounts must have a unique email address.'),$newUserName));
    
            // Check to see if email already exists
    -        if ( email_exists($ldapUserData[LDAP_INDEX_EMAIL]) )
    +    if ( email_exists($ldapUserData[LDAP_INDEX_EMAIL]) )
                    return new WP_Error('ldapcreate_emailconflict', sprintf(__('<strong>ERROR</strong>: <strong>%s</strong> (%s) is already associated with another account.  All accounts (including the admin account) must have an unique email address.'),$ldapUserData[LDAP_INDEX_EMAIL],$newUserName));
    
            // we don't actually care about the WP password (since it's LDAP), but we need one for WP database
    -       $sPassword = generate_random_password();
    +       $sPassword = wp_generate_password();
            $user_id = wpmu_create_user( $newUserName, $sPassword, $ldapUserData[LDAP_INDEX_EMAIL] );
    
            if ( $user_id === false ) {
    @@ -36,9 +36,9 @@
            }
    
            //Update their first and last name from ldap
    -       update_usermeta( $user_id, 'first_name', $ldapUserData[LDAP_INDEX_GIVEN_NAME] );
    -       update_usermeta( $user_id, 'last_name', $ldapUserData[LDAP_INDEX_SURNAME] );
    -       update_usermeta( $user_id, 'ldap_login', 'true' );
    +       update_user_meta( $user_id, 'first_name', $ldapUserData[LDAP_INDEX_GIVEN_NAME] );
    +       update_user_meta( $user_id, 'last_name', $ldapUserData[LDAP_INDEX_SURNAME] );
    +       update_user_meta( $user_id, 'ldap_login', 'true' );
    
            //Set Public Display Name
            $displayName = get_site_option('ldapPublicDisplayName');
    @@ -58,7 +58,7 @@
            //This is for plugin events
            do_action('wpmu_activate_user', $user_id, $newUserPassword, false);
    
    -       $domain = strtolower( wp_specialchars( $newUserName ) );
    +       $domain = strtolower( esc_html( $newUserName ) );
            if( constant( "VHOST" ) == 'yes' ) {
                    $newdomain = $domain . "." . $current_site->domain;
                    $path = $base;
    @@ -91,50 +91,51 @@
    
     function wpmuLdapAuthenticate($ldapString, $loginUserName, $loginPassword) {
            $errors = new WP_Error;
    -        // Check that user is not flagged as a ldap account
    +    // Check that user is not flagged as a ldap account
            if ( username_exists($loginUserName) ) {
                    $loginObj = get_user_by('login',$loginUserName);
    -               $ldapMeta = get_user_meta($loginObj->ID,'ldap_login',true);
    -               if ($ldapMeta != 'true') {
    +        $ldapMeta = get_user_meta($loginObj->ID,'ldap_login',true);
    +        if ($ldapMeta != 'true') {
                            $errors->add('invalid_userpass', __('<strong>ERROR</strong>: Wrong username / password combination. LDAP Access Denied.'));
                            return array('result' => false,'errors' => $errors);
                    }
            }
    
    -        $server = new LDAP_ro($ldapString);
    +    $server = new LDAP_ro($ldapString);
            if (LDAP_DEBUG_MODE) {
                    echo "DEBUG: Attempting to authenticate user: $loginUserName";
    -               $server->DebugOn();
    +        $server->DebugOn();
            } else $server->DebugOff();
    -        // undefined now - going to populate it in $server->Authenticate
    -        $userDataArray = null;
    -        $result = $server->Authenticate ($loginUserName, $loginPassword, $userDataArray);
    -        if ($result == LDAP_OK) {
    +    // undefined now - going to populate it in $server->Authenticate
    +    $userDataArray = null;
    +    $result = $server->Authenticate ($loginUserName, $loginPassword, $userDataArray);
    +    if ($result == LDAP_OK) {
                    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) ) {
    +    }
    +    // handle both at once, for security
    +    else if ( ($result == LDAP_ERROR_USER_NOT_FOUND || $result == LDAP_ERROR_WRONG_PASSWORD) ) {
    +
                    if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: Wrong user/pass";
                    $errors->add('invalid_userpass',__('<strong>ERROR</strong>: Wrong username / password combination.'));
    -                return array('result' => false,'errors' => $errors);
    -        }
    +        return array('result' => false,'errors' => $errors);
    +    }
            // check security group
    -       else if ( $result == LDAP_ERROR_ACCESS_GROUP ){
    -               if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: not found in security group";
    +    else if ( $result == LDAP_ERROR_ACCESS_GROUP ){
    +        if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: not found in security group";
                    $errors->add('wrong_group',__('<strong>ERROR</strong>: Access denied - user not found in security access group(s).'));
    -                return array('result' => false,'errors' => $errors);
    -        }
    +        return array('result' => false,'errors' => $errors);
    +    }
            elseif ($result == LDAP_ERROR_DENIED_GROUP) {
                    if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: denied via securtiy groups";
                    $errors->add('deny_group',__('<strong>ERROR</strong>: Access denied - user found in security deny group(s).'));
    -                return array('result' => false,'errors' => $errors);
    +        return array('result' => false,'errors' => $errors);
            }
    -        // the trickle-through catch-all
    -        else {
    -               if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: unknown error (not user/password or security group based - something else is wrong";
    -                $errors->add('unknown_error',__('<strong>ERROR</strong>: Unknown error in LDAP Authentication.'));
    -                return array('result' => false,'errors' => $errors);
    -        }
    +    // the trickle-through catch-all
    +    else {
    +               if (LDAP_DEBUG_MODE) echo "DEBUG: Attempting to authenticate user: unknown error (not user/password or security group based - something else is wrong)";
    +        $errors->add('unknown_error',__('<strong>ERROR</strong>: Unknown error in LDAP Authentication.'));
    +        return array('result' => false,'errors' => $errors);
    +    }
     }
    
     /**
    @@ -145,15 +146,16 @@
      */
     function wpmuLdapProcess(&$loginObj, $loginUserName, $loginPassword, $userDataArray) {
            global $error;
    -        // is it configured to create WP accounts from LDAP accounts?
    -        $ldapCreateAcct = get_site_option("ldapCreateAcct");
    +    // is it configured to create WP accounts from LDAP accounts?
    +    $ldapCreateAcct = get_site_option("ldapCreateAcct");
    
            // call the registration function to create a wordpress user account for this
            // successfully authenticated user
    -       require_once( ABSPATH . WPINC . '/registration.php');
    +       require_once( ABSPATH . WPINC . '/user.php');
    
            // if the account doesn't already exist
            if ( !username_exists( $loginUserName ) ) {
    +        if( LDAP_DEBUG_MODE) echo "Local account does not exists.  I will create it.";
    
                    // Make the WP users automatically if we're configured to do so
                    if ($ldapCreateAcct ) {
    @@ -163,13 +165,13 @@
                                    $_REQUEST['redirect_to'] = $loginUserName . "/" . $_REQUEST['redirect_to'];
                            }
                            return wpmuLdapCreateWPUserFromLdap(array(      'newUserName' => $loginUserName,
    -                                                                       'newUserPassword' => $loginPassword,
    -                                                                       'ldapUserData' => $userDataArray));
    +                                                        'newUserPassword' => $loginPassword,
    +                                                        'ldapUserData' => $userDataArray));
                    }
    
                    // but if not configured to create 'em, exit with an error
                    else {
    -                       return new WP_Error('account_noexist', __('<strong>ERROR</strong>: A blogging account does not exist - contact your administrator.'));
    +            return new WP_Error('account_noexist', __('<strong>ERROR</strong>: A blogging account does not exist - contact your administrator.'));
                    }
            }
    
    @@ -178,20 +180,20 @@
    
            // At this point we must have a login object, but just in case something went wrong
            if (!$loginObj) {
    -               return new WP_Error('unknown_error', __('<strong>ERROR</strong>: Unknown error in LDAP Authentication.'));
    +        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_user_meta($loginObj->ID,'ldap_login',true);
            if ($ldapMeta != 'true') {
    -               if (!update_usermeta($loginObj->ID, 'ldap_login', 'true')) {
    -                       return new WP_Error('update_usermeta', __('<strong>ERROR</strong>: Error updating user meta information.'));
    +               if (!update_user_meta($loginObj->ID, 'ldap_login', 'true')) {
    +            return new WP_Error('update_user_meta', __('<strong>ERROR</strong>: Error updating user meta information.'));
                    }
            }
    
            // Handle blog removal for various reasons
            if(is_super_admin($loginObj->ID) === false) {
    -               if ($primary_blog = get_user_meta($loginObj->ID, "primary_blog", true)) {
    +        if ($primary_blog = get_user_meta($loginObj->ID, "primary_blog", true)) {
                            $details = get_blog_details( $primary_blog );
                            if( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) {
                                    // reset primary blog to #1 (or dashboard) and add subscriber role
    @@ -211,13 +213,13 @@
      * Searches the LDAP directory for the specified user
      */
     function wpmuLdapSearch($ldapString = array(),$in_username,&$userDataArray) {
    -        $server = new LDAP_ro($ldapString);
    -        $server->DebugOff();
    +    $server = new LDAP_ro($ldapString);
    +    $server->DebugOff();
    
    -        $attributes_to_get = array (get_site_option('ldapAttributeMail',LDAP_DEFAULT_ATTRIBUTE_MAIL),
    -                                    get_site_option('ldapAttributeGivenname',LDAP_DEFAULT_ATTRIBUTE_GIVENNAME),
    -                                    get_site_option('ldapAttributeSn',LDAP_DEFAULT_ATTRIBUTE_SN),
    -                                    get_site_option('ldapAttributePhone',LDAP_DEFAULT_ATTRIBUTE_PHONE));
    +    $attributes_to_get = array (get_site_option('ldapAttributeMail',LDAP_DEFAULT_ATTRIBUTE_MAIL),
    +                                get_site_option('ldapAttributeGivenname',LDAP_DEFAULT_ATTRIBUTE_GIVENNAME),
    +                                get_site_option('ldapAttributeSn',LDAP_DEFAULT_ATTRIBUTE_SN),
    +                                get_site_option('ldapAttributePhone',LDAP_DEFAULT_ATTRIBUTE_PHONE));
            $userDataArray = null;
    
            if ($server->DoSearchUsername($in_username, $attributes_to_get, $userDataArray) == LDAP_OK) {
    @@ -231,8 +233,8 @@
      */
     function wpmuLdapSearchUser($opts) {
    
    -        // Extract Inputs
    -        extract($opts);
    +    // Extract Inputs
    +    extract($opts);
            if (!isset($username))          $username = '';
            if (!isset($blog_id))           $blog_id = 1;
            if (!isset($new_role))          $new_role = 'subscriber';
    @@ -250,17 +252,17 @@
                                    }
                            }
                            $user = wpmuLdapCreateWPUserFromLdap(array(     'newUserName' => $username,
    -                                                               'ldapUserData' => $userDataArray,
    -                                                               'createBlog' => $createBlog));
    +                                                        'ldapUserData' => $userDataArray,
    +                                                        'createBlog' => $createBlog));
                            if ( is_wp_error($user) ) {
                                    return $user;
                            }
    -                       if ( is_a($user, 'WP_User') ) {
    +            if ( is_a($user, 'WP_User') ) {
                                    if ( $user_id = username_exists($username) ) {
                                            add_user_to_blog($blog_id, $user_id, $new_role);
    
                                            // Update User Meta
    -                                       update_usermeta($user_id, 'primary_blog', $blog_id );
    +                                       update_user_meta($user_id, 'primary_blog', $blog_id );
                                    }
                                    return array( true, $user_id );
                            } else {
    @@ -276,7 +278,7 @@
      * If users already exists (Local or LDAP) access will be granted to the specified blog
      */
     function wpmuLdapAddUserToBlog($user_id,$blog_id,$new_role = 'subscriber') {
    -        add_user_to_blog($blog_id, $user_id, $new_role);
    +    add_user_to_blog($blog_id, $user_id, $new_role);
            return true;
     }
    
    @@ -292,7 +294,7 @@
      * @author Sean Wedig (www.thecodelife.net)
      */
     function wpmuLdapDisableSignup() {
    -        wp_redirect(get_option('siteurl').'/wp-login.php?action=signupdisabled');
    +    wp_redirect(get_option('siteurl').'/wp-login.php?action=signupdisabled');
    
            $msg = stripslashes(get_site_option('ldapSignupMessage'));
     }
    @@ -305,22 +307,21 @@
     }
    
     /**
    -* Checks to make sure the user is added to the dashboard blog (if set) or else blog #1
    -*/
    + * Checks to make sure the user is added to the dashboard blog (if set) or else blog #1
    + */
     function wpmuUpdateBlogAccess($userid) {
            // reset primary blog to #1 (or dashboard) and add subscriber role
            if ($dashboard = get_site_option( 'dashboard_blog' )) {
    -               add_user_to_blog( $dashboard, $userid, get_site_option( 'default_user_role', 'subscriber' ) );
    -               update_usermeta($userid, "primary_blog", $dashboard);
    +        add_user_to_blog( $dashboard, $userid, get_site_option( 'default_user_role', 'subscriber' ) );
    +        update_user_meta($userid, "primary_blog", $dashboard);
            } else {
                    add_user_to_blog( '1', $userid, get_site_option( 'default_user_role', 'subscriber' ) );
    -               update_usermeta($userid, "primary_blog", 1);
    +               update_user_meta($userid, "primary_blog", 1);
            }
     }
    
     function wpmuLdapUsernamePasswordAuthenticate($user, $username, $password) {
            if ( is_a($user, 'WP_User') ) return $user;
    -
            // check that username and password are not empty
            if ( (empty($username) || empty($password)) ) {
                    return $user; // probably an WP_Error object, set in "wp_authenticate_username_password()"
    @@ -341,9 +342,9 @@
    
     function wpmuLdapCheckLdapMeta($userdata) {
            $ldapMeta = get_user_meta($userdata->ID,'ldap_login',true);
    -        if (isset($ldapMeta) && $ldapMeta == 'true')
    +    if (isset($ldapMeta) && $ldapMeta == 'true')
                    return new WP_Error('invalid_userpass', __('<strong>ERROR</strong>: Wrong username / password combination. Local Access Denied.'));
    -       return $userdata;
    +       return $userdata;
     }
    
     function wpmuLdapSSOAuthenticate($user, $username, $password) {
    @@ -410,7 +411,7 @@
     }
    
     /*
    -when in SSO mode we don.t need to forse a relog in so theis stops that
    +  when in SSO mode we don.t need to forse a relog in so theis stops that
     */
     function wpmuLdapSSODisableReauth($login_url){
            return str_replace('&reauth=1','',$login_url);
    @@ -424,11 +425,11 @@
            global $wp_admin_bar;
            $wp_admin_bar->remove_menu('new-user');
            $wp_admin_bar->add_menu( array(
    -               'id' => 'new-user',
    -               'title' => 'User',
    -               'href' => admin_url() . "users.php?page=wpmu_ldap_adduser.functions.php",
    -               'parent' => 'new-content',
    -               'meta' => array(
    -                       'title' => _x( 'User', 'add new from admin bar' ), 'new-user' ),
    -               ));
    +                                   'id' => 'new-user',
    +                                   'title' => 'User',
    +                                   'href' => admin_url() . "users.php?page=wpmu_ldap_adduser.functions.php",
    +                                   'parent' => 'new-content',
    +                                   'meta' => array(
    +                                                   'title' => _x( 'User', 'add new from admin bar' ), 'new-user' ),
    +                                   ));
     }
    diff -x .svn -ruN new/wpmuldap/lib/wpmu_ldap_admin.functions.php wpmuldap/trunk/lib/wpmu_ldap_admin.functions.php
    --- new/wpmuldap/lib/wpmu_ldap_admin.functions.php      2012-09-28 12:43:16.000000000 -0400
    +++ wpmuldap/trunk/lib/wpmu_ldap_admin.functions.php    2012-11-02 08:09:58.000000000 -0400
    @@ -29,7 +29,11 @@
            // Process POST Updates
            if ($_SERVER['REQUEST_METHOD'] == 'POST') wpmuProcessUpdates();
    
    -       $tab = $_GET['ldaptab'];
    +    $tab="";
    +    if(isset( $_GET['ldaptab']) )
    +        $tab = $_GET['ldaptab'];
    +
    +
            $allowedtabs = array('general','connection','attributes','updates');
     ?>
     <div class="wrap">
    @@ -70,7 +74,7 @@
                    }
    
                    # Test Ldap Connection
    -               if ($_POST['ldapTestConnection']) {
    +            if ( isset($_POST['ldapTestConnection']) && $_POST['ldapTestConnection']) {
                            if (wpmuLdapTestConnection())
                                    echo "<div id='message' class='updated fade'><p><b>LDAP Connection Test:</b> Successful!</p></div>";
                            else
    @@ -197,7 +201,13 @@
            $tBlogChecked = ''; $fBlogChecked = '';
            $tDisableSignup = ''; $fDisableSignup = '';
            $tCreateLocalUser = ''; $fCreateLocalUser = '';
    +    $tSSOChecked = '';  $fSSOChecked = '';
    +    $tAddUser = ''; $fAddUser = '';
    +    $tBulkAdd = ''; $fBulkAdd = '';
    +    $tLocalEmail = ''; $fLocalEmail = '';
    +    $tLDAPEmail = ''; $fLDAPEmail = '';
    
    +
            if ($ldapSSOEnabled) $tSSOChecked = "checked='checked'";
            else $fSSOChecked = "checked='checked'";
    
    @@ -378,6 +388,7 @@
            $tChecked = ''; $fChecked = '';
            $tLinWin = ''; $fLinWin = '';
            $tEnableSSL = ''; $fEnableSSL = '';
    +    $tEnableTLS = ''; $fEnableTLS = '';
    
            if($ldapAuth) $tChecked = "checked='checked'";
            else $fChecked = "checked='checked'";
    @@ -790,7 +801,7 @@
            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' );
    +               update_user_meta( $user->ID, 'ldap_login', 'true' );
            }
     }
    
    @@ -859,9 +870,9 @@
                    return;
    
            if ($_POST['ldapAccountType'] == 'LDAP')
    -               update_usermeta( $user_id, 'ldap_login', 'true' );
    +               update_user_meta( $user_id, 'ldap_login', 'true' );
            else
    -               delete_usermeta( $user_id, 'ldap_login' );
    +               delete_user_meta( $user_id, 'ldap_login' );
    
     } // wpmuUserFormLdapOptionUpdate()

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use a pastebin. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    Thread Starter pribis

    (@pribis)

    Sorry, my bad. Here is a link:


    https://pastebin.com/xrA66C1E

    b–

    Thread Starter pribis

    (@pribis)

    I had to look at the patch today and saw I must have forgotten to tell diff to ignore white space. Sorry about that.

    I found a couple of other issues. We develop with warnings on because we’ve been bit with deprecations warnings turning into errors in the past. You way want to do the same for development.

    We are on WP 3.4.2 with PHP 5.4. I found a fewif($_POST['...']) which throw warnings because they are not set. I changed these to if(isset($_POST['...'])){} (see wpmu_ldap_adduser.functions.php and the patch above).

    I also ran into a deprecation warning from wp for wpmu_ldap_adduser.functions.php:287 for translate_with_context($name). I’ve commented it out in our code for now. But this has been deprecated since 2.9 and I can’t even find it in the codex anymore. _x() is used now. I’m not sure how to use it though. Any ideas?

    Thanks. Other than these small things, the plugin works well.

    brian

    Thread Starter pribis

    (@pribis)

    Added

    wpmu_ldap_adduser.functions.php:176
    global $error;

    Since an error on adding a user would barf accessing a nonexistent $error variable.

    Thread Starter pribis

    (@pribis)

    Here is another go at the diff. Excluded spaces this time. Found a couple more deprecated functions in the add user function file.

    https://pastebin.com/qtZXsUVz

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Minor fixes’ is closed to new replies.