docs: fix a typo in history file
[bbaumbach/samba-autobuild/.git] / source3 / winbindd / idmap_rfc2307.c
index 668a7a4e28e5759f55c8411e21972022215e6cab..2b3223829e2e36d98283249c7a329ad95c46bffa 100644 (file)
@@ -30,6 +30,8 @@
 #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.
@@ -78,7 +80,7 @@ static NTSTATUS idmap_rfc2307_ads_check_connection(struct idmap_domain *dom)
        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 {
@@ -193,10 +195,10 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
        }
 
        /* 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;
@@ -227,6 +229,7 @@ static void idmap_rfc2307_map_sid_results(struct idmap_rfc2307_context *ctx,
 
        for (i = 0; i < count; i++) {
                char *name;
+               struct dom_sid sid;
                enum lsa_SidType lsa_type;
                struct id_map *map;
                uint32_t id;
@@ -275,7 +278,7 @@ static void idmap_rfc2307_map_sid_results(struct idmap_rfc2307_context *ctx,
                   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) {
@@ -299,6 +302,7 @@ static void idmap_rfc2307_map_sid_results(struct idmap_rfc2307_context *ctx,
                }
 
                map->status = ID_MAPPED;
+               sid_copy(map->sid, &sid);
        }
 }
 
@@ -454,6 +458,7 @@ static NTSTATUS idmap_rfc_2307_sids_to_names(TALLOC_CTX *mem_ctx,
                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
@@ -465,7 +470,7 @@ static NTSTATUS idmap_rfc_2307_sids_to_names(TALLOC_CTX *mem_ctx,
 
                if (!b) {
                        DEBUG(1, ("Lookup sid %s failed.\n",
-                                 sid_string_dbg(ids[i]->sid)));
+                                 dom_sid_str_buf(ids[i]->sid, &buf)));
                        continue;
                }
 
@@ -491,7 +496,8 @@ static NTSTATUS idmap_rfc_2307_sids_to_names(TALLOC_CTX *mem_ctx,
 
                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;
                }
@@ -743,12 +749,7 @@ out:
 
 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);
@@ -833,7 +834,7 @@ err:
        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,