summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-11-25 01:31:07 +0000
committerAndrew Tridgell <tridge@samba.org>2001-11-25 01:31:07 +0000
commitcb697dd72a51daa14f174fae4fede2b86e7a7fd2 (patch)
treeeabbb7d47cc28bc4b3562904101022e26d871d4e /source3/libads
parent3906f9dff6f83e0075ae3d08709a35a629e97fa7 (diff)
downloadsamba-cb697dd72a51daa14f174fae4fede2b86e7a7fd2.tar.gz
samba-cb697dd72a51daa14f174fae4fede2b86e7a7fd2.tar.bz2
samba-cb697dd72a51daa14f174fae4fede2b86e7a7fd2.zip
added "net ads user" and "net ads group" commands
(This used to be commit f482583139eedb75a23c7a720dca4e8fb7070fd5)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap.c24
1 files changed, 14 insertions, 10 deletions
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
@@ -178,6 +178,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
*/
int ads_find_machine_acct(ADS_STRUCT *ads, void **res, const char *host)
@@ -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)) {