lib: Remove timeval_set()
[samba.git] / source3 / winbindd / idmap_rfc2307.c
index a747ff1f3bf73c4d455a5c44094c71861678746d..2b3223829e2e36d98283249c7a329ad95c46bffa 100644 (file)
@@ -31,6 +31,7 @@
 #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.
@@ -79,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 {
@@ -197,7 +198,7 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
        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;
@@ -228,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;
@@ -276,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) {
@@ -300,6 +302,7 @@ static void idmap_rfc2307_map_sid_results(struct idmap_rfc2307_context *ctx,
                }
 
                map->status = ID_MAPPED;
+               sid_copy(map->sid, &sid);
        }
 }
 
@@ -746,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);