Changeset 204 for branches/samba-3.2.x/source/winbindd/winbindd_cm.c
- Timestamp:
- May 20, 2009, 6:46:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/winbindd/winbindd_cm.c
r149 r204 847 847 if (NT_STATUS_IS_OK(result)) { 848 848 /* Ensure creds are stored for NTLMSSP authenticated pipe access. */ 849 cli_init_creds(*cli, machine_account, domain->name, machine_password);849 cli_init_creds(*cli, machine_account, lp_workgroup(), machine_password); 850 850 goto session_setup_done; 851 851 } … … 872 872 if (NT_STATUS_IS_OK(result)) { 873 873 /* Ensure creds are stored for NTLMSSP authenticated pipe access. */ 874 cli_init_creds(*cli, machine_account, domain->name, machine_password);874 cli_init_creds(*cli, machine_account, lp_workgroup(), machine_password); 875 875 goto session_setup_done; 876 876 } … … 909 909 910 910 /* Fall back to anonymous connection, this might fail later */ 911 DEBUG(10,("cm_prepare_connection: falling back to anonymous " 912 "connection for DC %s\n", 913 controller )); 911 914 912 915 if (NT_STATUS_IS_OK(cli_session_setup(*cli, "", NULL, 0, … … 979 982 } 980 983 984 /******************************************************************* 985 Add a dcname and sockaddr_storage pair to the end of a dc_name_ip 986 array. 987 988 Keeps the list unique by not adding duplicate entries. 989 990 @param[in] mem_ctx talloc memory context to allocate from 991 @param[in] domain_name domain of the DC 992 @param[in] dcname name of the DC to add to the list 993 @param[in] pss Internet address and port pair to add to the list 994 @param[in,out] dcs array of dc_name_ip structures to add to 995 @param[in,out] num_dcs number of dcs returned in the dcs array 996 @return true if the list was added to, false otherwise 997 *******************************************************************/ 998 981 999 static bool add_one_dc_unique(TALLOC_CTX *mem_ctx, const char *domain_name, 982 1000 const char *dcname, struct sockaddr_storage *pss, 983 1001 struct dc_name_ip **dcs, int *num) 984 1002 { 1003 int i = 0; 1004 985 1005 if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) { 986 1006 DEBUG(10, ("DC %s was in the negative conn cache\n", dcname)); 987 1007 return False; 988 1008 } 1009 1010 /* Make sure there's no duplicates in the list */ 1011 for (i=0; i<*num; i++) 1012 if (addr_equal(&(*dcs)[i].ss, pss)) 1013 return False; 989 1014 990 1015 *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1); … … 1118 1143 1119 1144 /******************************************************************* 1120 Retreive a list of IP address for domain controllers. Fill in 1121 the dcs[] with results. 1145 Retrieve a list of IP addresses for domain controllers. 1146 1147 The array is sorted in the preferred connection order. 1148 1149 @param[in] mem_ctx talloc memory context to allocate from 1150 @param[in] domain domain to retrieve DCs for 1151 @param[out] dcs array of dcs that will be returned 1152 @param[out] num_dcs number of dcs returned in the dcs array 1153 @return always true 1122 1154 *******************************************************************/ 1123 1155 … … 1135 1167 is_our_domain = strequal(domain->name, lp_workgroup()); 1136 1168 1169 /* If not our domain, get the preferred DC, by asking our primary DC */ 1137 1170 if ( !is_our_domain 1138 1171 && get_dc_name_via_netlogon(domain, dcname, &ss) 1139 && add_one_dc_unique(mem_ctx, domain->name, dcname, &ss, dcs, num_dcs) ) 1172 && add_one_dc_unique(mem_ctx, domain->name, dcname, &ss, dcs, 1173 num_dcs) ) 1140 1174 { 1141 1175 char addr[INET6_ADDRSTRLEN]; … … 1164 1198 1165 1199 /* Do the site-specific AD dns lookup first. */ 1166 get_sorted_dc_list(domain->alt_name, sitename, &ip_list, &iplist_size, True); 1167 1200 get_sorted_dc_list(domain->alt_name, sitename, &ip_list, 1201 &iplist_size, True); 1202 1203 /* Add ips to the DC array. We don't look up the name 1204 of the DC in this function, but we fill in the char* 1205 of the ip now to make the failed connection cache 1206 work */ 1168 1207 for ( i=0; i<iplist_size; i++ ) { 1169 1208 char addr[INET6_ADDRSTRLEN]; … … 1183 1222 } 1184 1223 1185 /* Now we add DCs from the main AD dns lookup. */ 1186 get_sorted_dc_list(domain->alt_name, NULL, &ip_list, &iplist_size, True); 1224 /* Now we add DCs from the main AD DNS lookup. */ 1225 get_sorted_dc_list(domain->alt_name, NULL, &ip_list, 1226 &iplist_size, True); 1187 1227 1188 1228 for ( i=0; i<iplist_size; i++ ) { … … 1197 1237 num_dcs); 1198 1238 } 1239 1240 SAFE_FREE(ip_list); 1241 iplist_size = 0; 1199 1242 } 1200 1243 1201 /* try standard netbios queries if no ADS */ 1202 1203 if (iplist_size==0) { 1204 get_sorted_dc_list(domain->name, NULL, &ip_list, &iplist_size, False); 1205 } 1206 1207 /* FIXME!! this is where we should re-insert the GETDC requests --jerry */ 1208 1209 /* now add to the dc array. We'll wait until the last minute 1210 to look up the name of the DC. But we fill in the char* for 1211 the ip now in to make the failed connection cache work */ 1212 1213 for ( i=0; i<iplist_size; i++ ) { 1214 char addr[INET6_ADDRSTRLEN]; 1215 print_sockaddr(addr, sizeof(addr), 1216 &ip_list[i].ss); 1217 add_one_dc_unique(mem_ctx, domain->name, addr, 1218 &ip_list[i].ss, dcs, num_dcs); 1219 } 1220 1221 SAFE_FREE( ip_list ); 1244 /* Try standard netbios queries if no ADS */ 1245 if (*num_dcs == 0) { 1246 get_sorted_dc_list(domain->name, NULL, &ip_list, &iplist_size, 1247 False); 1248 1249 for ( i=0; i<iplist_size; i++ ) { 1250 char addr[INET6_ADDRSTRLEN]; 1251 print_sockaddr(addr, sizeof(addr), 1252 &ip_list[i].ss); 1253 add_one_dc_unique(mem_ctx, 1254 domain->name, 1255 addr, 1256 &ip_list[i].ss, 1257 dcs, 1258 num_dcs); 1259 } 1260 1261 SAFE_FREE(ip_list); 1262 iplist_size = 0; 1263 } 1222 1264 1223 1265 return True; 1224 1266 } 1267 1268 /******************************************************************* 1269 Find and make a connection to a DC in the given domain. 1270 1271 @param[in] mem_ctx talloc memory context to allocate from 1272 @param[in] domain domain to find a dc in 1273 @param[out] dcname NetBIOS or FQDN of DC that's connected to 1274 @param[out] pss DC Internet address and port 1275 @param[out] fd fd of the open socket connected to the newly found dc 1276 @return true when a DC connection is made, false otherwise 1277 *******************************************************************/ 1225 1278 1226 1279 static bool find_new_dc(TALLOC_CTX *mem_ctx, … … 1901 1954 netlogon pipe. */ 1902 1955 1956 if (!domain->conn.netlogon_pipe->dc) { 1957 return false; 1958 } 1959 1903 1960 *ppdc = domain->conn.netlogon_pipe->dc; 1904 1961 return True; … … 1926 1983 goto done; 1927 1984 } 1985 1928 1986 1929 1987 /*
Note:
See TracChangeset
for help on using the changeset viewer.