LDAPMod **mods = NULL;
const char *type;
char *id_str;
- char *sid;
+ struct dom_sid_buf sid;
char *dn;
int rc = -1;
id_str = talloc_asprintf(memctx, "%lu", (unsigned long)map->xid.id);
CHECK_ALLOC_DONE(id_str);
- sid = talloc_strdup(memctx, sid_string_talloc(memctx, map->sid));
- CHECK_ALLOC_DONE(sid);
-
dn = talloc_asprintf(memctx, "%s=%s,%s",
get_attr_key2string(sidmap_attr_list, LDAP_ATTR_SID),
- sid,
+ dom_sid_str_buf(map->sid, &sid),
ctx->suffix);
CHECK_ALLOC_DONE(dn);
smbldap_make_mod(smbldap_get_ldap(ctx->smbldap_state), entry, &mods,
get_attr_key2string(sidmap_attr_list, LDAP_ATTR_SID),
- sid);
+ sid.buf);
if ( ! mods) {
DEBUG(2, ("ERROR: No mods?\n"));
smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_SID_ENTRY);
- DEBUG(10, ("Set DN %s (%s -> %s)\n", dn, sid, id_str));
+ DEBUG(10, ("Set DN %s (%s -> %s)\n", dn, sid.buf, id_str));
rc = smbldap_add(ctx->smbldap_state, dn, mods);
ldap_mods_free(mods, True);
ldap_get_option(smbldap_get_ldap(ctx->smbldap_state),
LDAP_OPT_ERROR_STRING, &ld_error);
DEBUG(0,("ldap_set_mapping_internals: Failed to add %s to %lu "
- "mapping [%s]\n", sid,
+ "mapping [%s]\n", sid.buf,
(unsigned long)map->xid.id, type));
DEBUG(0, ("ldap_set_mapping_internals: Error was: %s (%s)\n",
ld_error ? ld_error : "(NULL)", ldap_err2string (rc)));
}
DEBUG(10,("ldap_set_mapping: Successfully created mapping from %s to "
- "%lu [%s]\n", sid, (unsigned long)map->xid.id, type));
+ "%lu [%s]\n", sid.buf, (unsigned long)map->xid.id, type));
ret = NT_STATUS_OK;
attr_list = get_attr_list(memctx, sidmap_attr_list);
if ( ! ids[1]) {
+ struct dom_sid_buf buf;
/* if we are requested just one mapping use the simple filter */
filter = talloc_asprintf(memctx, "(&(objectClass=%s)(%s=%s))",
LDAP_OBJ_IDMAP_ENTRY,
LDAP_ATTRIBUTE_SID,
- sid_string_talloc(memctx, ids[0]->sid));
+ dom_sid_str_buf(ids[0]->sid, &buf));
CHECK_ALLOC_DONE(filter);
DEBUG(10, ("Filter: [%s]\n", filter));
} else {
bidx = idx;
for (i = 0; (i < IDMAP_LDAP_MAX_IDS) && ids[idx]; i++, idx++) {
+ struct dom_sid_buf buf;
filter = talloc_asprintf_append_buffer(filter, "(%s=%s)",
LDAP_ATTRIBUTE_SID,
- sid_string_talloc(memctx,
- ids[idx]->sid));
+ dom_sid_str_buf(ids[idx]->sid, &buf));
CHECK_ALLOC_DONE(filter);
}
filter = talloc_asprintf_append_buffer(filter, "))");
{
struct idmap_tdb2_context *ctx;
NTSTATUS ret;
- char *ksidstr, *kidstr;
+ char *kidstr;
+ struct dom_sid_buf sid_str;
struct idmap_tdb_common_context *commonctx;
struct idmap_tdb2_set_mapping_context state;
return NT_STATUS_INVALID_PARAMETER;
}
- ksidstr = kidstr = NULL;
+ kidstr = NULL;
/* TODO: should we filter a set_mapping using low/high filters ? */
goto done;
}
- ksidstr = sid_string_talloc(ctx, map->sid);
- if (ksidstr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- state.ksidstr = ksidstr;
+ state.ksidstr = dom_sid_str_buf(map->sid, &sid_str);
state.kidstr = kidstr;
ret = dbwrap_trans_do(commonctx->db, idmap_tdb2_set_mapping_action,
&state);
done:
- talloc_free(ksidstr);
talloc_free(kidstr);
return ret;
}
status = dbwrap_fetch_bystring(commonctx->db, keystr, keystr, &data);
if (!NT_STATUS_IS_OK(status)) {
- char *sidstr;
+ struct dom_sid_buf sidstr;
struct idmap_tdb2_set_mapping_context store_state;
DEBUG(10,("Record %s not found\n", keystr));
goto done;
}
- sidstr = sid_string_talloc(keystr, map->sid);
- if (!sidstr) {
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- store_state.ksidstr = sidstr;
+ store_state.ksidstr = dom_sid_str_buf(map->sid, &sidstr);
store_state.kidstr = keystr;
ret = dbwrap_trans_do(commonctx->db,
{
NTSTATUS ret;
TDB_DATA data;
- char *keystr;
+ struct dom_sid_buf keystr;
unsigned long rec_id = 0;
struct idmap_tdb_common_context *commonctx;
struct idmap_tdb2_context *ctx;
ctx = talloc_get_type(commonctx->private_data,
struct idmap_tdb2_context);
- keystr = sid_string_talloc(tmp_ctx, map->sid);
- if (keystr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ dom_sid_str_buf(map->sid, &keystr);
- DEBUG(10,("Fetching record %s\n", keystr));
+ DEBUG(10, ("Fetching record %s\n", keystr.buf));
/* Check if sid is present in database */
- ret = dbwrap_fetch_bystring(commonctx->db, tmp_ctx, keystr, &data);
+ ret = dbwrap_fetch_bystring(commonctx->db, tmp_ctx, keystr.buf, &data);
if (!NT_STATUS_IS_OK(ret)) {
char *idstr;
struct idmap_tdb2_set_mapping_context store_state;
- DEBUG(10,(__location__ " Record %s not found\n", keystr));
+ DBG_DEBUG("Record %s not found\n", keystr.buf);
if (ctx->script == NULL) {
ret = NT_STATUS_NONE_MAPPED;
goto done;
}
- ret = idmap_tdb2_script(ctx, map, "SIDTOID %s", keystr);
+ ret = idmap_tdb2_script(ctx, map, "SIDTOID %s", keystr.buf);
if (!NT_STATUS_IS_OK(ret)) {
goto done;
}
goto done;
}
- store_state.ksidstr = keystr;
+ store_state.ksidstr = keystr.buf;
store_state.kidstr = idstr;
ret = dbwrap_trans_do(commonctx->db,
if (sscanf((const char *)data.dptr, "UID %lu", &rec_id) == 1) { /* Try a UID record. */
map->xid.id = rec_id;
map->xid.type = ID_TYPE_UID;
- DEBUG(10,("Found uid record %s -> %s \n", keystr, (const char *)data.dptr ));
+ DBG_DEBUG("Found uid record %s -> %s \n",
+ keystr.buf,
+ (const char *)data.dptr );
ret = NT_STATUS_OK;
} else if (sscanf((const char *)data.dptr, "GID %lu", &rec_id) == 1) { /* Try a GID record. */
map->xid.id = rec_id;
map->xid.type = ID_TYPE_GID;
- DEBUG(10,("Found gid record %s -> %s \n", keystr, (const char *)data.dptr ));
+ DBG_DEBUG("Found gid record %s -> %s \n",
+ keystr.buf,
+ (const char *)data.dptr );
ret = NT_STATUS_OK;
} else { /* Unknown record type ! */
- DEBUG(2, ("Found INVALID record %s -> %s\n", keystr, (const char *)data.dptr));
+ DBG_WARNING("Found INVALID record %s -> %s\n",
+ keystr.buf,
+ (const char *)data.dptr);
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
}
struct idmap_tdb_common_context *ctx;
struct idmap_tdb_common_set_mapping_context state;
NTSTATUS ret;
- char *ksidstr = NULL;
+ struct dom_sid_buf ksidstr;
char *kidstr = NULL;
if (!map || !map->sid) {
goto done;
}
- ksidstr = sid_string_talloc(ctx, map->sid);
- if (ksidstr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- state.ksidstr = ksidstr;
+ state.ksidstr = dom_sid_str_buf(map->sid, &ksidstr);
state.kidstr = kidstr;
ret = dbwrap_trans_do(ctx->db, idmap_tdb_common_set_mapping_action,
&state);
done:
- talloc_free(ksidstr);
talloc_free(kidstr);
return ret;
}
{
NTSTATUS ret;
TDB_DATA data;
- char *keystr;
+ struct dom_sid_buf keystr;
unsigned long rec_id = 0;
struct idmap_tdb_common_context *ctx;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
talloc_get_type_abort(dom->private_data,
struct idmap_tdb_common_context);
- keystr = sid_string_talloc(tmp_ctx, map->sid);
- if (keystr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ dom_sid_str_buf(map->sid, &keystr);
- DEBUG(10, ("Fetching record %s\n", keystr));
+ DEBUG(10, ("Fetching record %s\n", keystr.buf));
/* Check if sid is present in database */
- ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr, &data);
+ ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr.buf, &data);
if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(10, ("Record %s not found\n", keystr));
+ DEBUG(10, ("Record %s not found\n", keystr.buf));
ret = NT_STATUS_NONE_MAPPED;
goto done;
}
map->xid.id = rec_id;
map->xid.type = ID_TYPE_UID;
DEBUG(10,
- ("Found uid record %s -> %s \n", keystr,
+ ("Found uid record %s -> %s \n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_OK;
map->xid.id = rec_id;
map->xid.type = ID_TYPE_GID;
DEBUG(10,
- ("Found gid record %s -> %s \n", keystr,
+ ("Found gid record %s -> %s \n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_OK;
} else { /* Unknown record type ! */
DEBUG(2,
- ("Found INVALID record %s -> %s\n", keystr,
+ ("Found INVALID record %s -> %s\n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
bool is_online = true;
struct winbindd_tdc_domain *d = NULL;
char *trust_type = NULL;
+ struct dom_sid_buf buf;
d = &dom_list[i];
domain = find_domain_from_name_noinit(d->domain_name);
"%s\\%s\\%s\\%s\\%s\\%s\\%s\\%s\n",
d->domain_name,
d->dns_name ? d->dns_name : "",
- sid_string_talloc(state->mem_ctx, &d->sid),
+ dom_sid_str_buf(&d->sid, &buf),
trust_type,
trust_is_transitive(d) ? "Yes" : "No",
trust_is_inbound(d) ? "Yes" : "No",
extra_data = talloc_strdup(state->mem_ctx, "");
for (i=0; i<trusts.count; i++) {
+ struct dom_sid_buf buf;
if (trusts.array[i].sid == NULL) {
continue;
extra_data = talloc_asprintf_append_buffer(
extra_data, "%s\\%s\\%s\\%u\\%u\\%u\n",
trusts.array[i].netbios_name, trusts.array[i].dns_name,
- sid_string_talloc(state->mem_ctx, trusts.array[i].sid),
+ dom_sid_str_buf(trusts.array[i].sid, &buf),
trusts.array[i].trust_flags,
(uint32_t)trusts.array[i].trust_type,
trusts.array[i].trust_attributes);
}
if (state->request->data.list_all_domains && !have_own_domain) {
+ struct dom_sid_buf buf;
extra_data = talloc_asprintf_append_buffer(
extra_data, "%s\\%s\\%s\n", domain->name,
domain->alt_name != NULL ?
domain->alt_name :
domain->name,
- sid_string_talloc(state->mem_ctx, &domain->sid));
+ dom_sid_str_buf(&domain->sid, &buf));
}
extra_data_len = strlen(extra_data);