#include "smbldap.h"
#include "nsswitch/winbind_client.h"
#include "lib/winbind_util.h"
+#include "libcli/security/dom_sid.h"
+#include "lib/global_contexts.h"
/*
* Config and connection info per domain.
ctx = talloc_get_type(dom->private_data, struct idmap_rfc2307_context);
dom_name = ctx->ldap_domain ? ctx->ldap_domain : dom->name;
- status = ads_idmap_cached_connection(&ctx->ads, dom_name);
+ status = ads_idmap_cached_connection(dom_name, ctx, &ctx->ads);
if (ADS_ERR_OK(status)) {
ctx->ldap = ctx->ads->ldap.ld;
} else {
}
/* assume anonymous if we don't have a specified user */
- ret = smbldap_init(mem_ctx, winbind_event_context(), url,
+ ret = smbldap_init(mem_ctx, global_event_context(), url,
(user_dn == NULL), user_dn, secret,
&ctx->smbldap_state);
- SAFE_FREE(secret);
+ BURN_FREE_STR(secret);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("ERROR: smbldap_init (%s) failed!\n", url));
goto done;
for (i = 0; i < count; i++) {
char *name;
+ struct dom_sid sid;
enum lsa_SidType lsa_type;
struct id_map *map;
uint32_t id;
the following call will not recurse so this is safe */
(void)winbind_on();
/* Lookup name from PDC using lsa_lookup_names() */
- b = winbind_lookup_name(dom_name, name, map->sid, &lsa_type);
+ b = winbind_lookup_name(dom_name, name, &sid, &lsa_type);
(void)winbind_off();
if (!b) {
}
map->status = ID_MAPPED;
+ sid_copy(map->sid, &sid);
}
}
enum lsa_SidType lsa_type;
struct id_map *id = ids[i];
struct idmap_rfc2307_map *map = &maps[i];
+ struct dom_sid_buf buf;
bool b;
/* by default calls to winbindd are disabled
if (!b) {
DEBUG(1, ("Lookup sid %s failed.\n",
- sid_string_dbg(ids[i]->sid)));
+ dom_sid_str_buf(ids[i]->sid, &buf)));
continue;
}
default:
DEBUG(1, ("Unknown lsa type %d for sid %s\n",
- lsa_type, sid_string_dbg(id->sid)));
+ lsa_type,
+ dom_sid_str_buf(id->sid, &buf)));
id->status = ID_UNMAPPED;
continue;
}
static int idmap_rfc2307_context_destructor(struct idmap_rfc2307_context *ctx)
{
- if (ctx->ads != NULL) {
- /* we own this ADS_STRUCT so make sure it goes away */
- ctx->ads->is_mine = True;
- ads_destroy( &ctx->ads );
- ctx->ads = NULL;
- }
+ TALLOC_FREE(ctx->ads);
if (ctx->smbldap_state != NULL) {
smbldap_free_struct(&ctx->smbldap_state);
return status;
}
-static struct idmap_methods rfc2307_methods = {
+static const struct idmap_methods rfc2307_methods = {
.init = idmap_rfc2307_initialize,
.unixids_to_sids = idmap_rfc2307_unixids_to_sids,
.sids_to_unixids = idmap_rfc2307_sids_to_unixids,