From cb697dd72a51daa14f174fae4fede2b86e7a7fd2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 25 Nov 2001 01:31:07 +0000 Subject: added "net ads user" and "net ads group" commands (This used to be commit f482583139eedb75a23c7a720dca4e8fb7070fd5) --- source3/libads/ldap.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/libads/ldap.c') diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 812c44e7d7..604a11aa5b 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -177,6 +177,19 @@ int ads_connect(ADS_STRUCT *ads) } +/* + do a general ADS search +*/ +int ads_search(ADS_STRUCT *ads, void **res, + const char *exp, + const char **attrs) +{ + *res = NULL; + return ldap_search_s(ads->ld, ads->bind_path, + LDAP_SCOPE_SUBTREE, exp, (char **)attrs, 0, (LDAPMessage **)res); +} + + /* find a machine account given a hostname */ @@ -188,9 +201,7 @@ int ads_find_machine_acct(ADS_STRUCT *ads, void **res, const char *host) /* the easiest way to find a machine account anywhere in the tree is to look for hostname$ */ asprintf(&exp, "(samAccountName=%s$)", host); - *res = NULL; - ret = ldap_search_s(ads->ld, ads->bind_path, - LDAP_SCOPE_SUBTREE, exp, NULL, 0, (LDAPMessage **)res); + ret = ads_search(ads, res, exp, NULL); free(exp); return ret; } @@ -320,7 +331,6 @@ void ads_dump(ADS_STRUCT *ads, void *res) char *field; LDAPMessage *msg; BerElement *b; - char *this_dn; struct { char *name; void (*handler)(const char *, struct berval **); @@ -332,12 +342,6 @@ void ads_dump(ADS_STRUCT *ads, void *res) for (msg = ldap_first_entry(ads->ld, (LDAPMessage *)res); msg; msg = ldap_next_entry(ads->ld, msg)) { - this_dn = ldap_get_dn(ads->ld, (LDAPMessage *)res); - if (this_dn) { - printf("Dumping: %s\n", this_dn); - } - ldap_memfree(this_dn); - for (field = ldap_first_attribute(ads->ld, msg, &b); field; field = ldap_next_attribute(ads->ld, msg, b)) { -- cgit