Ticket #60: jabberd-ldap-append-realm-2.diff

File jabberd-ldap-append-realm-2.diff, 1.2 KB (added by smoku, 20 months ago)

Patch by Andrew Klang <andrew.klang@…>

  • c2s/authreg_ldap.c

    old new  
    3939#define AR_LDAP_FLAGS_STARTTLS  (0x1) 
    4040#define AR_LDAP_FLAGS_SSL       (0x2) 
    4141#define AR_LDAP_FLAGS_V3        (0x4) 
     42#define AR_LDAP_FLAGS_APPEND_REALM (0x8) 
    4243 
    4344/** internal structure, holds our data */ 
    4445typedef struct moddata_st 
     
    138139        return NULL; 
    139140    } 
    140141 
    141     snprintf(filter, 1024, "(%s=%s)", data->uidattr, username); 
     142    if (data->flags & AR_LDAP_FLAGS_APPEND_REALM) { 
     143        snprintf(filter, 1024, "(%s=%s@%s)", data->uidattr, username, realm); 
     144    } else { 
     145        snprintf(filter, 1024, "(%s=%s)", data->uidattr, username); 
     146    } 
    142147 
    143148    if(ldap_search_s(data->ld, basedn, LDAP_SCOPE_SUBTREE, filter, no_attrs, 0, &result)) 
    144149    { 
     
    283288    if(config_get(ar->c2s->config, "authreg.ldap.ssl") != NULL) 
    284289      data->flags |= AR_LDAP_FLAGS_SSL; 
    285290 
     291    if(config_get(ar->c2s->config, "authreg.ldap.append-realm") != NULL) 
     292      data->flags |= AR_LDAP_FLAGS_APPEND_REALM; 
     293 
    286294    if((data->flags & AR_LDAP_FLAGS_STARTTLS) && (data->flags & AR_LDAP_FLAGS_SSL)) { 
    287295        log_write(ar->c2s->log, LOG_ERR, "ldap: not possible to use both SSL and starttls"); 
    288296        return 1;