diff options
author | Sumit Bose <sbose@redhat.com> | 2010-10-21 10:13:46 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-10-22 07:21:49 -0400 |
commit | 4534c103b193b74452ea81bf12ffaceb1901728a (patch) | |
tree | 7719850dbeaa3a3358c031f8f0b8397e424aae7c /src/providers/ldap/sdap_async_connection.c | |
parent | 3fd2f20f23c909f7d3d4dfd1b8b1c0f8cc87dfe1 (diff) | |
download | sssd-4534c103b193b74452ea81bf12ffaceb1901728a.tar.gz sssd-4534c103b193b74452ea81bf12ffaceb1901728a.tar.xz sssd-4534c103b193b74452ea81bf12ffaceb1901728a.zip |
Add ldap_deref option
Diffstat (limited to 'src/providers/ldap/sdap_async_connection.c')
-rw-r--r-- | src/providers/ldap/sdap_async_connection.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c index b62050521..e4ca96242 100644 --- a/src/providers/ldap/sdap_async_connection.c +++ b/src/providers/ldap/sdap_async_connection.c @@ -28,6 +28,24 @@ #define LDAP_X_SSSD_PASSWORD_EXPIRED 0x555D +errno_t deref_string_to_val(const char *str, int *val) +{ + if (strcasecmp(str, "never") == 0) { + *val = LDAP_DEREF_NEVER; + } else if (strcasecmp(str, "searching") == 0) { + *val = LDAP_DEREF_SEARCHING; + } else if (strcasecmp(str, "finding") == 0) { + *val = LDAP_DEREF_FINDING; + } else if (strcasecmp(str, "always") == 0) { + *val = LDAP_DEREF_ALWAYS; + } else { + DEBUG(1, ("Illegal deref option [%s].\n", str)); + return EINVAL; + } + + return EOK; +} + /* ==Connect-to-LDAP-Server=============================================== */ struct sdap_connect_state { @@ -61,6 +79,8 @@ struct tevent_req *sdap_connect_send(TALLOC_CTX *memctx, int msgid; char *errmsg = NULL; bool ldap_referrals; + const char *ldap_deref; + int ldap_deref_val; req = tevent_req_create(memctx, &state, struct sdap_connect_state); if (!req) return NULL; @@ -130,6 +150,23 @@ struct tevent_req *sdap_connect_send(TALLOC_CTX *memctx, goto fail; } + /* Set alias dereferencing */ + ldap_deref = dp_opt_get_string(opts->basic, SDAP_DEREF); + if (ldap_deref != NULL) { + ret = deref_string_to_val(ldap_deref, &ldap_deref_val); + if (ret != EOK) { + DEBUG(1, ("deref_string_to_val failed.\n")); + goto fail; + } + + lret = ldap_set_option(state->sh->ldap, LDAP_OPT_DEREF, &ldap_deref_val); + if (lret != LDAP_OPT_SUCCESS) { + DEBUG(1, ("Failed to set deref option to %d\n", ldap_deref_val)); + goto fail; + } + + } + ret = setup_ldap_connection_callbacks(state->sh, state->ev); if (ret != EOK) { DEBUG(1, ("setup_ldap_connection_callbacks failed.\n")); |