diff options
author | Tim Potter <tpot@samba.org> | 2002-11-06 05:14:15 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-11-06 05:14:15 +0000 |
commit | ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9 (patch) | |
tree | de41e9906d94ea9b2a1d2c12920d23b9640d3e83 /source3/libsmb | |
parent | d21a06bbb44a0044657de38c1eb544be8c335918 (diff) | |
download | samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.tar.gz samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.tar.bz2 samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.zip |
Merge of get_dc_list() api change from HEAD.
(This used to be commit 6ba7847ce2756fde94e530fd0bf2a055f3e27373)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/namequery.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 40a353fa8b..8fdf145625 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1206,54 +1206,87 @@ NT GETDC call, UNICODE, NT domain SID and uncle tom cobbley and all... #endif /* defined(I_HATE_WINDOWS_REPLY_CODE) */ } - /******************************************************** - Get the IP address list of the PDC/BDC's of a Domain. + Get the IP address list of the primary domain controller + for a domain. *********************************************************/ -BOOL get_dc_list(BOOL pdc_only, const char *group, struct in_addr **ip_list, int *count) +BOOL get_pdc_ip(const char *domain, struct in_addr *ip) { - int name_type = pdc_only ? 0x1B : 0x1C; + struct in_addr *ip_list; + int count; + + /* Look up #1B name */ + + if (!internal_resolve_name(domain, 0x1b, &ip_list, &count)) + return False; + + SMB_ASSERT(count == 1); + + *ip = ip_list[0]; + SAFE_FREE(ip_list); + + return True; +} +/******************************************************** + Get the IP address list of the domain controllers for + a domain. +*********************************************************/ + +BOOL get_dc_list(const char *domain, struct in_addr **ip_list, int *count) +{ /* * If it's our domain then * use the 'password server' parameter. */ - if (strequal(group, lp_workgroup())) { + if (strequal(domain, lp_workgroup())) { char *p; char *pserver = lp_passwordserver(); fstring name; int num_adresses = 0; struct in_addr *return_iplist = NULL; - if (! *pserver) - return internal_resolve_name(group, name_type, ip_list, count); + if (!*pserver) + return internal_resolve_name( + domain, 0x1C, ip_list, count); p = pserver; + while (next_token(&p,name,LIST_SEP,sizeof(name))) { if (strequal(name, "*")) - return internal_resolve_name(group, name_type, ip_list, count); + return internal_resolve_name( + domain, 0x1C, ip_list, count); num_adresses++; } + if (num_adresses == 0) - return internal_resolve_name(group, name_type, ip_list, count); + return internal_resolve_name( + domain, 0x1C, ip_list, count); + + return_iplist = (struct in_addr *)malloc( + num_adresses * sizeof(struct in_addr)); - return_iplist = (struct in_addr *)malloc(num_adresses * sizeof(struct in_addr)); - if(return_iplist == NULL) { + if (return_iplist == NULL) { DEBUG(3,("get_dc_list: malloc fail !\n")); return False; } + p = pserver; *count = 0; + while (next_token(&p,name,LIST_SEP,sizeof(name))) { struct in_addr name_ip; if (resolve_name( name, &name_ip, 0x20) == False) continue; return_iplist[(*count)++] = name_ip; } + *ip_list = return_iplist; + return (*count != 0); - } else - return internal_resolve_name(group, name_type, ip_list, count); + } + + return internal_resolve_name(domain, 0x1C, ip_list, count); } |