*/
#include "includes.h"
+#include "version.h"
#ifdef HAVE_LDAP
TODO : add a negative connection cache in here leveraged off of the one
found in the rpc code. --jerry
*/
-static BOOL ads_try_connect(ADS_STRUCT *ads, const char *server, unsigned port)
+static BOOL ads_try_connect(ADS_STRUCT *ads, const char *server, uint_t port)
{
char *srv;
return False;
}
ads->ldap_port = port;
- ads->ldap_ip = *interpret_addr2(srv);
+ ads->ldap_ip = interpret_addr2(srv);
free(srv);
return True;
if (!ads->auth.user_name) {
/* by default use the machine account */
fstring myname;
- fstrcpy(myname, global_myname());
+ fstrcpy(myname, lp_netbios_name());
strlower_m(myname);
asprintf(&ads->auth.user_name, "HOST/%s", myname);
}
if (!in_val) return NULL;
- value = talloc_zero(ctx, sizeof(struct berval));
+ value = talloc_zero(ctx, struct berval);
if (value == NULL)
return NULL;
if (in_val->bv_len == 0) return value;
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++); /* count values */
- values = (char ** ) talloc_zero(ctx, (i+1)*sizeof(char *));
+ values = talloc_zero_array_p(ctx, char *, i+1);
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
if (!in_vals) return NULL;
for (i=0; in_vals[i]; i++); /* count values */
- values = (char **) talloc_zero(ctx, (i+1)*sizeof(char *));
+ values = talloc_zero_array_p(ctx, char *, i+1);
if (!values) return NULL;
for (i=0; in_vals[i]; i++) {
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(&search_attrs, attrs))) {
+ search_attrs = str_list_copy(ctx, attrs);
+ if (search_attrs == NULL) {
rc = LDAP_NO_MEMORY;
goto done;
}
ldap_controls_free(rcontrols);
done:
- talloc_destroy(ctx);
+ talloc_free(ctx);
/* if/when we decide to utf8-encode attrs, take out this next line */
str_list_free(&search_attrs);
else {
/* This would be the utf8-encoded version...*/
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
- if (!(str_list_copy(&search_attrs, attrs)))
- {
+ search_attrs = str_list_copy(ctx, attrs);
+ if (search_attrs == NULL) {
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
rc = LDAP_NO_MEMORY;
goto done;
}
done:
- talloc_destroy(ctx);
+ talloc_free(ctx);
/* if/when we decide to utf8-encode attrs, take out this next line */
str_list_free(&search_attrs);
return ADS_ERROR(rc);
#define ADS_MODLIST_ALLOC_SIZE 10
LDAPMod **mods;
- if ((mods = (LDAPMod **) talloc_zero(ctx, sizeof(LDAPMod *) *
- (ADS_MODLIST_ALLOC_SIZE + 1))))
+ if ((mods = talloc_zero_array_p(ctx, LDAPMod *, ADS_MODLIST_ALLOC_SIZE + 1))) {
/* -1 is safety to make sure we don't go over the end.
need to reset it to NULL before doing ldap modify */
mods[ADS_MODLIST_ALLOC_SIZE] = (LDAPMod *) -1;
+ }
return mods;
}
for (curmod=0; modlist[curmod] && modlist[curmod] != (LDAPMod *) -1;
curmod++);
if (modlist[curmod] == (LDAPMod *) -1) {
- if (!(modlist = talloc_realloc(ctx, modlist,
+ if (!(modlist = talloc_realloc(modlist,
(curmod+ADS_MODLIST_ALLOC_SIZE+1)*sizeof(LDAPMod *))))
return ADS_ERROR(LDAP_NO_MEMORY);
memset(&modlist[curmod], 0,
*mods = modlist;
}
- if (!(modlist[curmod] = talloc_zero(ctx, sizeof(LDAPMod))))
+ if (!(modlist[curmod] = talloc_zero(ctx, LDAPMod)))
return ADS_ERROR(LDAP_NO_MEMORY);
modlist[curmod]->mod_type = talloc_strdup(ctx, name);
if (mod_op & LDAP_MOD_BVALUES) {
"user", "computer", NULL};
const char *servicePrincipalName[5] = {NULL, NULL, NULL, NULL, NULL};
char *psp, *psp2;
- unsigned acct_control;
- unsigned exists=0;
+ uint_t acct_control;
+ uint_t exists=0;
LDAPMessage *res;
status = ads_find_machine_acct(ads, (void **)&res, hostname);
}
}
done:
- talloc_destroy(ctx);
+ talloc_free(ctx);
return ret;
}
for (i=0; values[i]; i++) {
printf("%s: ", field);
for (j=0; j<values[i]->bv_len; j++) {
- printf("%02X", (unsigned char)values[i]->bv_val[j]);
+ printf("%02X", (uint8_t)values[i]->bv_val[j]);
}
printf("\n");
}
struct uuid {
uint32_t i1;
- uint16 i2;
- uint16 i3;
- uint8 s[8];
+ uint16_t i2;
+ uint16_t i3;
+ uint8_t s[8];
};
static void dump_guid(const char *field, struct berval **values)
/* parse secdesc */
if (!sec_io_desc("sd", &psd, &ps, 1)) {
prs_mem_free(&ps);
- talloc_destroy(ctx);
+ talloc_free(ctx);
return;
}
if (psd) ads_disp_sd(psd);
prs_mem_free(&ps);
- talloc_destroy(ctx);
+ talloc_free(ctx);
}
/*
fn(NULL, NULL, data_area); /* completed an entry */
}
- talloc_destroy(ctx);
+ talloc_free(ctx);
}
/**
ads_set_sd_error:
ads_msgfree(ads, res);
prs_mem_free(&ps_wire);
- talloc_destroy(ctx);
+ talloc_free(ctx);
return ret;
}
*num_values = ldap_count_values(values);
- ret = talloc(mem_ctx, sizeof(char *) * (*num_values+1));
+ ret = talloc_array(mem_ctx, char *, *num_values+1);
if (!ret) {
ldap_value_free(values);
return NULL;
attr;
attr = ldap_next_attribute(ads->ld, (LDAPMessage *)msg, ptr)) {
/* we ignore the fact that this is utf8, as all attributes are ascii... */
- if (strnequal(attr, expected_range_attrib, strlen(expected_range_attrib))) {
+ if (strncasecmp(attr, expected_range_attrib, strlen(expected_range_attrib)) == 0) {
range_attr = attr;
break;
}
}
if (!attr) {
ber_free(ptr, 0);
- /* nothing here - this feild is just empty */
+ /* nothing here - this field is just empty */
*more_strings = False;
return NULL;
}
return NULL;
}
- strings = talloc_realloc(mem_ctx, current_strings,
+ strings = talloc_realloc(current_strings,
sizeof(*current_strings) *
(*num_strings + num_new_strings));
for (i=0; values[i]; i++)
/* nop */ ;
- (*sids) = talloc(mem_ctx, sizeof(DOM_SID) * i);
+ (*sids) = talloc_array(mem_ctx, DOM_SID, i);
if (!(*sids)) {
ldap_value_free_len(values);
return 0;
p = strchr(value, ':');
if (!p) {
- talloc_destroy(ctx);
+ talloc_free(ctx);
DEBUG(1, ("ads_server_info: returned ldap server name did not contain a ':' "
"so was deemed invalid\n"));
return ADS_ERROR(LDAP_DECODING_ERROR);
ads->config.ldap_server_name = strdup(p+1);
p = strchr(ads->config.ldap_server_name, '$');
if (!p || p[1] != '@') {
- talloc_destroy(ctx);
+ talloc_free(ctx);
DEBUG(1, ("ads_server_info: returned ldap server name (%s) does not contain '$@'"
" so was deemed invalid\n", ads->config.ldap_server_name));
SAFE_FREE(ads->config.ldap_server_name);
DEBUG(4,("time offset is %d seconds\n", ads->auth.time_offset));
}
- talloc_destroy(ctx);
+ talloc_free(ctx);
return ADS_SUCCESS;
}