summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-07-08 16:04:24 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-07-09 14:27:27 +0200
commit93bd0fbd1147371122612af88ed8a3c4534112ae (patch)
tree7f0f31c2036208a9c9e54fdc942ddf5e73cd9384 /src/db
parent3c0c7a9c6f1a6874afbf4fa5516be7a0bc8ef470 (diff)
downloadsssd-93bd0fbd1147371122612af88ed8a3c4534112ae.tar.gz
sssd-93bd0fbd1147371122612af88ed8a3c4534112ae.tar.bz2
sssd-93bd0fbd1147371122612af88ed8a3c4534112ae.zip
DB: sysdb_search_user_by_name: search by both name and alias
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb_ops.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 710a23b0..ff8fb008 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -248,6 +248,8 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
struct ldb_message **msgs = NULL;
struct ldb_dn *basedn;
size_t msgs_count = 0;
+ char *sanitized_name;
+ char *filter;
int ret;
tmp_ctx = talloc_new(NULL);
@@ -255,13 +257,26 @@ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- basedn = sysdb_user_dn(sysdb, tmp_ctx, domain, name);
+ basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb,
+ SYSDB_TMPL_USER_BASE, domain->name);
if (!basedn) {
ret = ENOMEM;
goto done;
}
- ret = sysdb_search_entry(tmp_ctx, sysdb, basedn, LDB_SCOPE_BASE, NULL,
+ ret = sss_filter_sanitize(tmp_ctx, name, &sanitized_name);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ filter = talloc_asprintf(tmp_ctx, SYSDB_PWNAM_FILTER, sanitized_name,
+ sanitized_name);
+ if (!filter) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = sysdb_search_entry(tmp_ctx, sysdb, basedn, LDB_SCOPE_SUBTREE, filter,
attrs?attrs:def_attrs, &msgs_count, &msgs);
if (ret) {
goto done;