Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
Added realm on ldapvcard to append to user
Browse files Browse the repository at this point in the history
  • Loading branch information
omula committed Feb 16, 2014
1 parent 979f24e commit 93feaf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions etc/sm.xml.dist.in
Expand Up @@ -263,6 +263,11 @@
<pwattr>jabberPassword</pwattr>
-->

<!-- Realm to append to uidattr. -->
<!--
<realm>example.org</realm>
-->

<!-- see authreg.ldapfull in c2s.xml for description. -->
<!--
<validattr>valid</validattr>
Expand Down
17 changes: 15 additions & 2 deletions storage/storage_ldapvcard.c
Expand Up @@ -44,6 +44,8 @@ typedef struct drvdata_st {
LDAP *ld;
const char *uri;

const char *realm; // server id to be appended to uid

const char *binddn;
const char *bindpw;
const char *basedn;
Expand Down Expand Up @@ -442,7 +444,12 @@ static st_ret_t _st_ldapvcard_get(st_driver_t drv, const char *type, const char
ldap_value_free(vals);
continue;
}
strncpy(jid,vals[0],sizeof(jid)-1); jid[sizeof(jid)-1]='\0';
if( data->realm == NULL ) {
strncpy(jid,vals[0],sizeof(jid)-1); jid[sizeof(jid)-1]='\0';
} else {
snprintf(jid, 2048, "%s@%s", vals[0], data->realm);
}

ldap_value_free(vals);

vals = (char **)ldap_get_values(data->ld,entry,"displayName");
Expand Down Expand Up @@ -554,7 +561,7 @@ static void _st_ldapvcard_free(st_driver_t drv) {
DLLEXPORT st_ret_t st_init(st_driver_t drv)
{
drvdata_t data;
const char *uri, *basedn, *srvtype_s;
const char *uri, *realm, *basedn, *srvtype_s;
int srvtype_i;

log_write(drv->st->log, LOG_NOTICE, "ldapvcard: initializing");
Expand All @@ -565,6 +572,11 @@ DLLEXPORT st_ret_t st_init(st_driver_t drv)
return st_FAILED;
}

realm = config_get_one(drv->st->config, "storage.ldapvcard.realm", 0);
if(realm != NULL) {
log_write(drv->st->log, LOG_NOTICE, "ldapvcard: defined realm %s", realm);
}

basedn = config_get_one(drv->st->config, "storage.ldapvcard.basedn", 0);
if(basedn == NULL) {
log_write(drv->st->log, LOG_ERR, "ldapvcard: no basedn specified in config file");
Expand All @@ -588,6 +600,7 @@ DLLEXPORT st_ret_t st_init(st_driver_t drv)
drv->private = (void *) data;

data->uri = uri;
data->realm = realm;
data->basedn = basedn;
data->srvtype = srvtype_i;

Expand Down

0 comments on commit 93feaf3

Please sign in to comment.