Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6678413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:14:25+00:00 2026-05-26T04:14:25+00:00

I posted this question on serverfault.com, but I had no answer, so I’m trying

  • 0

I posted this question on serverfault.com, but I had no answer, so I’m trying here…
Is it possible to mix mod_ssl and mod_auth_ldap so that the authentication is done with the client certificate and authorizations with mod_auth_ldap (Require ldap-group)? If so, can you give me some pointer? Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:14:25+00:00Added an answer on May 26, 2026 at 4:14 am

    OK, for those interested, apache requires the presence of an AuthType directive and the validation of the username by some module.

    So I have written a very short module that accepts AuthType Any and accepts any username.

    The configuration looks like that:

    <Location /slaptest>
        Allow from all
        SSLVerifyClient require
        SSLVerifyDepth 1
    
        SSLUserName SSL_CLIENT_S_DN_CN
    
        AuthType Any
        AuthAnyAuthoritative on
    
        AuthLDAPURL "ldaps://vldap-rectech/ou=XXX,ou=YYY,o=ZZZ?cn"
        AuthzLDAPAuthoritative on
        AuthLDAPBindDN "cn=UUU,ou=Users,ou=XXX,ou=YYY,o=ZZZ"
        AuthLDAPBindPassword "******"
        AuthLDAPGroupAttributeIsDN on
        AuthLDAPGroupAttribute member
        AuthLDAPRemoteUserIsDN off
        Require valid-user
        Require ldap-group cn=ADMIN,ou=Groups,ou=XXX,ou=YYY,o=ZZZ
    </Location>
    

    UPDATE:

    The code of the module is listed below. It defines the following directives:

    AuthAnyAuthoritative on/off

    AuthAnyCheckBasic on/off

    If AuthAnyCheckBasic is on, the module will check that the username obtained from the certificate matches the on in the Authorization header.

    #include "apr_strings.h"
    #include "apr_md5.h"            /* for apr_password_validate */
    #include "apr_lib.h"            /* for apr_isspace */
    #include "apr_base64.h"         /* for apr_base64_decode et al */
    #define APR_WANT_STRFUNC        /* for strcasecmp */
    #include "apr_want.h"
    
    #include "ap_config.h"
    #include "httpd.h"
    #include "http_config.h"
    #include "http_core.h"
    #include "http_log.h"
    #include "http_protocol.h"
    #include "http_request.h"
    #include "ap_provider.h"
    
    #include "mod_auth.h"
    
    typedef struct {
        int authoritative;
        int checkBasic;
    } auth_any_config_rec;
    
    static void *create_auth_any_dir_config(apr_pool_t *p, char *d)
    {
        auth_any_config_rec *conf = apr_pcalloc(p, sizeof(*conf));
    
        /* Any failures are fatal. */
        conf->authoritative = 1;
        conf->checkBasic = 0;
    
        return conf;
    }
    
    static const command_rec auth_any_cmds[] =
    {
        AP_INIT_FLAG("AuthAnyAuthoritative", ap_set_flag_slot,
                     (void *)APR_OFFSETOF(auth_any_config_rec, authoritative),
                     OR_AUTHCFG,
                     "Set to 'Off' to allow access control to be passed along to "
                     "lower modules if the UserID is not known to this module"),
        AP_INIT_FLAG("AuthAnyCheckBasic", ap_set_flag_slot,
                     (void *)APR_OFFSETOF(auth_any_config_rec, checkBasic),
                     OR_AUTHCFG,
                     "Set to 'On' to compare the username with the one in the "
                     "Authorization header"),
        {NULL}
    };
    
    module AP_MODULE_DECLARE_DATA auth_any_module;
    
    static void note_basic_auth_failure(request_rec *r)
    {
        apr_table_setn(r->err_headers_out,
                       (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authenticate"
                                                       : "WWW-Authenticate",
                       apr_pstrcat(r->pool, "Basic realm=\"", ap_auth_name(r),
                                   "\"", NULL));
    }
    
    /* Determine user ID, and check if it really is that user, for HTTP
     * basic authentication...
     */
    static int authenticate_any_user(request_rec *r)
    {
        auth_any_config_rec *conf = ap_get_module_config(r->per_dir_config,
                                                           &auth_any_module);
    
        /* Are we configured to be Basic auth? */
        const char *current_auth = ap_auth_type(r);
        if (!current_auth || strcasecmp(current_auth, "Any")) {
            return DECLINED;
        }
    
        if (!r->user) {
            return conf->authoritative ? HTTP_UNAUTHORIZED : DECLINED;
        }
    
        if (conf->checkBasic) {
            /* Get the appropriate header */
            const char *auth_line = apr_table_get(r->headers_in,
                    (PROXYREQ_PROXY == r->proxyreq)
                            ? "Proxy-Authorization"
                            : "Authorization");
    
            if (!auth_line) {
                note_basic_auth_failure(r);
                return HTTP_UNAUTHORIZED;
            }
    
            if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
                /* Client tried to authenticate using wrong auth scheme */
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
                              "client used wrong authentication scheme: %s", r->uri);
                note_basic_auth_failure(r);
                return HTTP_UNAUTHORIZED;
            }
    
            /* Skip leading spaces. */
            while (apr_isspace(*auth_line)) {
                auth_line++;
            }
    
            char *decoded_line = apr_palloc(r->pool, apr_base64_decode_len(auth_line) + 1);
            int length = apr_base64_decode(decoded_line, auth_line);
            /* Null-terminate the string. */
            decoded_line[length] = '\0';
    
            const char *user = ap_getword_nulls(r->pool, (const char**)&decoded_line, ':');
    
            if (strcasecmp(user, r->user)) {
                return HTTP_UNAUTHORIZED;
            }
        }
    
        r->ap_auth_type = "Any";
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                "Accepting user: %s", r->user);
    
        return OK;
    }
    
    static void register_hooks(apr_pool_t *p)
    {
        ap_hook_check_user_id(authenticate_any_user,NULL,NULL,APR_HOOK_MIDDLE);
    }
    
    module AP_MODULE_DECLARE_DATA auth_any_module =
    {
        STANDARD20_MODULE_STUFF,
        create_auth_any_dir_config,    /* dir config creater */
        NULL,                          /* dir merger --- default is to override */
        NULL,                          /* server config */
        NULL,                          /* merge server config */
        auth_any_cmds,                 /* command apr_table_t */
        register_hooks                 /* register hooks */
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[I posted a similar question on serverfault.com, but had very little feedback so trying
I once posted this question, but had no answer at all, this time, the
I had posted this question on superuser but didn't get a helpful response. Thought
I posted this question on the django-users list, but haven't had a reply there
I have posted this question a while ago but got a partial answer to
I posted this question on MWS forum but, didn't get an answer. So, I'm
I posted this question on webmasters.stackexchange.com but no reply, so I thought I'd try
I posted this question here before but there were no responses. I may have
I posted this question: https://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help
I am using the BlockingQueue code posted in this question , but realized I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.