Can’t get
-
Our internal LDAP server has changed so I need to use the wpdirauth_filterquery filter in order to properly validate user logins. I was using the solution in this prior support thread however I cannot get wpdirauth_filterquery to fire.
I’ve tried modifying my functions.php (I am using TwentyThirteen as my theme) as well as a dedicated plugin. The only thing I’ve been able to get to work is to modify the plugin code itself. For obvious reasons I don’t really want to do that. My preference would be to write a simple plugin so I don’t have to worry about a theme update modifying functions.php either.
This is what I added to my functions.php:
function mgcAdjustDirAuthFilter($strCurrentFilter,$strFilter,$strUsername) { error_log(sprintf("%s::%s\n", basename(__FILE__), __LINE__), 3, "/var/tmp/log.txt"); return "(&(objectClass=user)(objectCategory=person)($strFilter=$strUsername))"; } add_filter(‘wpdirauth_filterquery’,’mgcAdjustDirAuthFilter’,1,3);But it never runs. I added error_log() statements within the function to trace execution but the text never appears and the filter is unchanged from the default after apply_filters runs from line 393 of wpDirAuth.php:
$filterQuery = apply_filters('wpdirauth_filterquery',$filterQuery,$filter,$username);Since that didn’t work I tried creating simple plugin:
<?php /** * @package MGC-wpDirAuth * @version 1.0 */ /* Plugin Name: MGC-wpDirAuth Plugin URI: http://ww.wp.xz.cn/extend/plugins/tbd/ Description: This plugin defines a filter for the wpDirAuth plugin which configures the querty to work with Mentor's LDAP configuration. Author: Mike Walsh Version: 1.0 Author URI: http://michaelwalsh.org/ */ function mgc_AdjustDirAuthFilter($strCurrentFilter,$strFilter,$strUsername) { error_log(sprintf("%s::%s\n", basename(__FILE__), __LINE__), 3, "/var/tmp/log.txt"); return "(&(objectClass=user)(objectCategory=person)($strFilter=$strUsername))"; } // Setup the wpdirauth_filterquery hook function mgc_wpDirAuth_init() { error_log(sprintf("%s::%s\n", basename(__FILE__), __LINE__), 3, "/var/tmp/log.txt"); add_filter(‘wpdirauth_filterquery’,’mgc_AdjustDirAuthFilter’,1,3); } add_action( 'init', 'mgc_wpDirAuth_init' ); ?>Like the addition to functions.php, the filter never runs. The ‘init’ action does fire and I see the entry in the error log file. I’ve tried various priorities and other hooks (e.g. plugins_loaded and a couple others) but it didn’t make a difference. The site this is running only has one other plugin running which does nothing more than look up information from our LDAP server.
I assume I am missing something obvious I simply can’t see from staring at it.
The topic ‘Can’t get’ is closed to new replies.