summaryrefslogtreecommitdiff
path: root/source3/libads/ldap_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libads/ldap_user.c')
-rw-r--r--source3/libads/ldap_user.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source3/libads/ldap_user.c b/source3/libads/ldap_user.c
index 2e38e7a00d..7efe5338f3 100644
--- a/source3/libads/ldap_user.c
+++ b/source3/libads/ldap_user.c
@@ -30,10 +30,15 @@ ADS_STATUS ads_find_user_acct(ADS_STRUCT *ads, void **res, const char *user)
ADS_STATUS status;
char *exp;
const char *attrs[] = {"*", NULL};
+ char *escaped_user = escape_ldap_string_alloc(user);
+ if (!escaped_user) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
- asprintf(&exp, "(samAccountName=%s)", user);
+ asprintf(&exp, "(samAccountName=%s)", escaped_user);
status = ads_search(ads, res, exp, attrs);
- free(exp);
+ SAFE_FREE(exp);
+ SAFE_FREE(escaped_user);
return status;
}