SAFE_FREE(base);
if (ads_count_replies(ads, res) != 1) {
+ ads_msgfree(ads, res);
return NULL;
}
new_ln = wkn_ln - bind_ln;
- ret = wkn_dn_exp[0];
+ ret = SMB_STRDUP(wkn_dn_exp[0]);
for (i=1; i < new_ln; i++) {
char *s;
free(s);
}
+ ads_msgfree(ads, res);
ads_memfree(ads, wkn_dn);
ldap_value_free(wkn_dn_exp);
ldap_value_free(bind_dn_exp);
char *upn, *userdn;
LDAPMessage *res=NULL;
int rc = -1;
+ char *ou_str = NULL;
if (argc < 1) return net_ads_user_usage(argc, argv);
goto done;
}
- if (opt_container == NULL) {
- opt_container = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
+ if (opt_container) {
+ ou_str = SMB_STRDUP(opt_container);
+ } else {
+ ou_str = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
}
- status = ads_add_user_acct(ads, argv[0], opt_container, opt_comment);
+ status = ads_add_user_acct(ads, argv[0], ou_str, opt_comment);
if (!ADS_ERR_OK(status)) {
d_fprintf(stderr, "Could not add user %s: %s\n", argv[0],
if (res)
ads_msgfree(ads, res);
ads_destroy(&ads);
+ SAFE_FREE(ou_str);
return rc;
}
ADS_STATUS status;
LDAPMessage *res=NULL;
int rc = -1;
+ char *ou_str = NULL;
if (argc < 1) {
return net_ads_group_usage(argc, argv);
goto done;
}
- if (opt_container == NULL) {
- opt_container = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
+ if (opt_container) {
+ ou_str = SMB_STRDUP(opt_container);
+ } else {
+ ou_str = ads_default_ou_string(ads, WELL_KNOWN_GUID_USERS);
}
- status = ads_add_group_acct(ads, argv[0], opt_container, opt_comment);
+ status = ads_add_group_acct(ads, argv[0], ou_str, opt_comment);
if (ADS_ERR_OK(status)) {
d_printf("Group %s added\n", argv[0]);
if (res)
ads_msgfree(ads, res);
ads_destroy(&ads);
+ SAFE_FREE(ou_str);
return rc;
}
LDAPMessage *res = NULL;
ou_str = ads_ou_string(ads, ou);
- asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path);
- free(ou_str);
+ if ((asprintf(&dn, "%s,%s", ou_str, ads->config.bind_path)) == -1) {
+ SAFE_FREE(ou_str);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
rc = ads_search_dn(ads, &res, dn, NULL);
ads_msgfree(ads, res);
}
}
+ SAFE_FREE( ou_str );
SAFE_FREE( dn );
return rc;