]> git.samba.org - samba.git/blobdiff - source3/winbindd/idmap_adex/gc_util.c
s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()
[samba.git] / source3 / winbindd / idmap_adex / gc_util.c
index 56bd9542f6682976d82a53969093bf319cdbcaa5..e4bf8d59d7a595c8dbe1e0a2c42dbf5d03648cc4 100644 (file)
@@ -23,6 +23,7 @@
 #include "idmap.h"
 #include "idmap_adex.h"
 #include "libads/cldap.h"
+#include "../libcli/ldap/ldap_ndr.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_IDMAP
@@ -106,6 +107,7 @@ done:
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
        struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply;
        TALLOC_CTX *frame = talloc_stackframe();
+       struct sockaddr_storage ss;
 
        if (!gc || !domain) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -125,8 +127,17 @@ done:
        nt_status = ads_ntstatus(ads_status);
        BAIL_ON_NTSTATUS_ERROR(nt_status);
 
+       if (!resolve_name(ads->config.ldap_server_name, &ss, 0x20, true)) {
+               DEBUG(5,("gc_find_forest_root: unable to resolve name %s\n",
+                        ads->config.ldap_server_name));
+               nt_status = NT_STATUS_IO_TIMEOUT;
+               /* This matches the old code which did the resolve in
+                * ads_cldap_netlogon_5 */
+               BAIL_ON_NTSTATUS_ERROR(nt_status);
+       }
+
        if (!ads_cldap_netlogon_5(frame,
-                                 ads->config.ldap_server_name,
+                                 &ss,
                                  ads->config.realm,
                                  &cldap_reply))
        {
@@ -719,7 +730,7 @@ done:
 
        *name = NULL;
 
-       sid_string = sid_binstring(frame, sid);
+       sid_string = ldap_encode_ndr_dom_sid(frame, sid);
        BAIL_ON_PTR_ERROR(sid_string, nt_status);
 
        filter = talloc_asprintf(frame, "(objectSid=%s)", sid_string);
@@ -776,11 +787,11 @@ done:
                msg_tmp = TALLOC_ARRAY(NULL, LDAPMessage*, 1);
                BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
        } else {
-               ads_tmp = TALLOC_REALLOC_ARRAY(*ads_list, *ads_list, ADS_STRUCT*,
+               ads_tmp = talloc_realloc(*ads_list, *ads_list, ADS_STRUCT*,
                                               count+1);
                BAIL_ON_PTR_ERROR(ads_tmp, nt_status);
 
-               msg_tmp = TALLOC_REALLOC_ARRAY(*msg_list, *msg_list, LDAPMessage*,
+               msg_tmp = talloc_realloc(*msg_list, *msg_list, LDAPMessage*,
                                               count+1);
                BAIL_ON_PTR_ERROR(msg_tmp, nt_status);
        }