Active Directory (AD) group authentication to view wordpress posts?

I think this should definitely be doable. I think I would first try to get one of the LDAP authentication plugins — like Simple LDAP Login or LDAP Login Password and Role Manager — working, and then write a small custom plugin to handle the content authorization.

Here’s a rough outline of the custom plugin’s main logic:

function checkContentAuthorization( $content )
{
    $authorization = array(
        'ldap group 1' => array(
            'authorizesCategories'  = array( 1, 14, 83 ),
            'authorizedPosts'       = array( 53, 48, 23, 432 )
        ),
        'ldap group 2' => array(
            'authorizesCategories'  = array( 54, 9, 34 ),
            'authorizedPosts'       = array( 48, 13, 29, 93 )
        ),
    )

    if( is_category() )
    {
        if( !in_array( $currentCategoryID, $authorization[ currentLDAPUser->groupName ][ 'authorizedCategories' ] )
            $content="Access denied";
    }
    elseif( is_single() )
    {
        if( !in_array( $currentPostID, $authorization[ currentLDAPUser->groupName ][ 'authorizedPosts' ] )
            $content="Access denied";
    }

    return $content;
}
add_filter( 'the_content', 'checkContentAuthorization' );

Obviously that’s a stripped down version and there’s a lot of details to fill in, but actually writing the plugin itself would take at least half a day. That should get you pointed in the right direction, though.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)