• Resolved Steve Cliff

    (@stevecliff)


    Currently I’m entering a value into Account Filter of “aoLdapKey” as our LDAP server doesn’t use the default of samAccountName.

    However I currently have to amend the PHP code for the following as there are two types of user in LDAP with different prefixes:

    $filterQuery = “($filter=$username)”;

    to

    filterQuery = “(|($filter=AA{$username})($filter=XX{$username}))”;

    This works ok but I’d love a way of doing this without amending the PHP every time a new version is pushed out.

    Is it possible at all?

    Thanks!
    Steve.

    https://www.ads-software.com/plugins/wpdirauth/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paul Gilzow

    (@gilzow)

    v1.7.14 added filter wpdirauth_filterquery.
    v1.7.15 amended filter to pass THREE parameters, instead of two.

    Will pass callback function three parameters: current AD filter and the username of the person attempting to authenticate. callback function will need to return a valid AD filter that can be used for looking up the user.

    add_filter('wpdirauth_filterquery','mycustomcallback',10,3);
    
    function mycustomcallback($strCurrentFilter,$strFilter,$strUsername)
    {
        return "(|($strFilter=AA{$strUsername})($strFilter=XX{$strUsername}))";
    }
    Thread Starter Steve Cliff

    (@stevecliff)

    Thanks for the info – I’m just on a training course at the minute so will see if I can get it to work over the weekend. Need to figure out how to use add_filter first though – never done that before – lol!

    Good news it can be done though ??

    Cheers,
    Steve.

    Plugin Author Paul Gilzow

    (@gilzow)

    just drop the example i posted above into the functions.php file of your theme, changing mycustomcallback to the function name you want to use. Something like:

    add_filter('wpdirauth_filterquery','steveCliffAdjustWpDirAuthFilter',10,3);
    
    function steveCliffAdjustWpDirAuthFilter($strCurrentFilter,$strFilter,$strUsername)
    {
        return "(|($strFilter=AA{$strUsername})($strFilter=XX{$strUsername}))";
    }
    Thread Starter Steve Cliff

    (@stevecliff)

    I broke out of training for lunch and tried this – works absolutely perfect – thanks very much !

    Plugin Author Paul Gilzow

    (@gilzow)

    good to hear. I’m going to go ahead then and mark this one as closed. though let me know if you run into an issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filter query – is it possible?’ is closed to new replies.