summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_ads.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 97b64a271c..a4ed3d50ea 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -574,7 +574,7 @@ static int ads_user_delete(int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
- LDAPMessage *res;
+ LDAPMessage *res = NULL;
char *userdn;
if (argc < 1) {
@@ -586,8 +586,9 @@ static int ads_user_delete(int argc, const char **argv)
}
rc = ads_find_user_acct(ads, &res, argv[0]);
- if (!ADS_ERR_OK(rc)) {
+ if (!ADS_ERR_OK(rc) || ads_count_replies(ads, res) != 1) {
d_printf("User %s does not exist.\n", argv[0]);
+ ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
}
@@ -595,7 +596,7 @@ static int ads_user_delete(int argc, const char **argv)
ads_msgfree(ads, res);
rc = ads_del_dn(ads, userdn);
ads_memfree(ads, userdn);
- if (!ADS_ERR_OK(rc)) {
+ if (ADS_ERR_OK(rc)) {
d_printf("User %s deleted\n", argv[0]);
ads_destroy(&ads);
return 0;