net ads info now reports the IP of the LDAP server as well as its name - very useful...
authorAndrew Tridgell <tridge@samba.org>
Tue, 30 Jul 2002 15:34:10 +0000 (15:34 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 30 Jul 2002 15:34:10 +0000 (15:34 +0000)
(This used to be commit fc0d5479b575c1f495b9251413eed18ec1e37e02)

source3/auth/auth_domain.c
source3/include/ads.h
source3/libads/ads_struct.c
source3/utils/net_ads.c

index f74f1bb9e89f393effd5cd1edacdbc6f5cdc9232..327d49144fda21420d49674b8e1adb7dbd6bc0ea 100644 (file)
@@ -46,6 +46,8 @@ static NTSTATUS ads_resolve_dc(fstring remote_machine,
                return NT_STATUS_NO_LOGON_SERVERS;              
        }
 
+       DEBUG(4,("ads_resolve_dc: realm=%s\n", ads->realm));
+
 #ifdef HAVE_ADS
        /* a full ads_connect() is actually overkill, as we don't srictly need
           to do the SASL auth in order to get the info we need, but libads
@@ -57,10 +59,10 @@ static NTSTATUS ads_resolve_dc(fstring remote_machine,
 
        fstrcpy(remote_machine, ads->ldap_server_name);
        strupper(remote_machine);
-       *dest_ip = *interpret_addr2(ads->ldap_server);
+       *dest_ip = ads->ldap_ip;
        ads_destroy(&ads);
        
-       if (!*remote_machine) {
+       if (!*remote_machine || is_zero_ip(*dest_ip)) {
                return NT_STATUS_NO_LOGON_SERVERS;              
        }
 
@@ -166,8 +168,8 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
                return NT_STATUS_NO_LOGON_SERVERS;
        
        /* Attempt connection */
-       result = cli_full_connection(cli, global_myname, server,
-                                    &dest_ip, 0, "IPC$", "IPC", "", "", "", 0);
+       result = cli_full_connection(cli, global_myname, remote_machine,
+                                    &dest_ip, 0, "IPC$", "IPC", "", "", "");
 
        if (!NT_STATUS_IS_OK(result)) {
                release_server_mutex();
index b3e18f18b8ddd29d1a63dbc2f1452df54ae49192..78d2fcf4b52dbcdeca5220321feb01e3e14a84f6 100644 (file)
@@ -17,6 +17,7 @@ typedef struct {
        char *password;
        char *user_name;
        char *server_realm;
+       struct in_addr ldap_ip;
 } ADS_STRUCT;
 
 typedef struct {
index 0be79673a0010997eb53d25d928b0cec8dbead37..af0b5d4143100ac95c1ba8f600c427428b2c3de0 100644 (file)
@@ -162,6 +162,7 @@ ADS_STRUCT *ads_init(const char *realm,
                        ads->ldap_server = strdup(lp_ads_server());
                }
                if (!ads->ldap_server || !ads->ldap_server[0]) {
+                       SAFE_FREE(ads->ldap_server);
                        ads->ldap_server = find_ldap_server(ads);
                }
        }
@@ -170,6 +171,11 @@ ADS_STRUCT *ads_init(const char *realm,
                ads->kdc_server = ads->ldap_server? strdup(ads->ldap_server) : NULL;
        }
 
+       if (ads->ldap_server) {
+               /* its very useful knowing the IP of the ldap server */
+               ads->ldap_ip = *interpret_addr2(ads->ldap_server);
+       }
+
        return ads;
 }
 
index fa3eac6bd39ea3cd201902dcfac717904a1f7e71..a449395641b9a82162ebeb5c7515fd923bba9c6f 100644 (file)
@@ -67,6 +67,7 @@ static int net_ads_info(int argc, const char **argv)
        }
 
        d_printf("LDAP server: %s\n", ads->ldap_server);
+       d_printf("LDAP server IP: %s\n", inet_ntoa(ads->ldap_ip));
        d_printf("LDAP server name: %s\n", ads->ldap_server_name);
        d_printf("Realm: %s\n", ads->realm);
        d_printf("Bind Path: %s\n", ads->bind_path);