From bb8349735f627ba4de2012f77ee3fa6ce491f394 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 2 Feb 2002 02:04:01 +0000 Subject: Minor bug fixes, plus support to remove a printer. Commented out optional attributes until a method for checking for their existence is done. (This used to be commit 538c19a6983e0423b94f743184263cd8ef9c701e) --- source3/libads/ldap.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 11 deletions(-) (limited to 'source3/libads/ldap.c') diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 293c885342..8dee73bde2 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -105,6 +105,23 @@ void ads_msgfree(ADS_STRUCT *ads, void *msg) ldap_msgfree(msg); } +/* + free up memory from various ads requests +*/ +void ads_memfree(ADS_STRUCT *ads, void *mem) +{ + if (!mem) return; + ldap_memfree(mem); +} + +/* + get a dn from search results +*/ +char *ads_get_dn(ADS_STRUCT *ads, void *res) +{ + return ldap_get_dn(ads->ld, res); +} + /* find a machine account given a hostname */ @@ -122,6 +139,24 @@ ADS_STATUS ads_find_machine_acct(ADS_STRUCT *ads, void **res, const char *host) return status; } +/* + duplicate an already-assembled list of values so that it can be + freed as part of the standard msgfree call +*/ +static char **ads_dup_values(char **values) +{ + char **newvals; + int i; +#define ADS_MAX_NUM_VALUES 32 + + for (i=0; values[i] && i0;i++); /* make sure the end of the list is NULL */ mods[i] = NULL; - ret = ldap_add_s(ads->ld, mod_dn, (LDAPMod **) mods); + ret = ldap_modify_s(ads->ld, mod_dn, (LDAPMod **) mods); return ADS_ERROR(ret); } @@ -293,6 +333,11 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ...) return ADS_ERROR(ret); } +ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn) +{ + return ADS_ERROR(ldap_delete(ads->ld, del_dn)); +} + /* build an org unit string if org unit is Computers or blank then assume a container, otherwise @@ -508,9 +553,9 @@ ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname) return status; } - hostnameDN = ldap_get_dn(ads->ld, (LDAPMessage *)res); + hostnameDN = ads_get_dn(ads, (LDAPMessage *)res); rc = ldap_delete_s(ads->ld, hostnameDN); - ldap_memfree(hostnameDN); + ads_memfree(ads, hostnameDN); if (rc != LDAP_SUCCESS) { return ADS_ERROR(rc); } -- cgit