Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.
Hello, The attached patch was removed from the message in the list, so I include it in this message body. Index: win32.c =================================================================== RCS file: /usr/local/cvs/cvsnt/windows-NT/win32.c,v retrieving revision 1.72 diff -u -r1.72 win32.c --- win32.c 24 Mar 2003 21:16:05 -0000 1.72 +++ win32.c 24 Oct 2003 12:11:14 -0000 @@ -369,8 +369,10 @@ static char pdc[1024]; NET_API_STATUS res; char *ptr; + wchar_t *domainName; // only fetch a domain controller if the machine is a domain member + w_pdc[0]=0; if(isDomainMember()) { ptr=strchr(name, '\\'); @@ -390,7 +392,10 @@ w_domain[numchars] = 0; // May fail for workgroup-only NT boxen (Patch from jonathan.gilligan at vanderbilt.edu) - NetGetAnyDCName(NULL,w_domain,(LPBYTE*)&w_pdc); + if (NetGetAnyDCName(NULL,w_domain,(LPBYTE*)&domainName)==NERR_Success) { + wcscpy(w_pdc,domainName); + NetApiBufferFree(domainName); + } name = ptr+1; } else @@ -398,7 +403,12 @@ if(NetWkstaUserGetInfo(NULL,1,(LPBYTE*)&wk_info)==NERR_Success) wcscpy(w_pdc,wk_info->wkui1_logon_server); else - NetGetAnyDCName(NULL,NULL,(LPBYTE*)&w_pdc); + { + if (NetGetAnyDCName(NULL,NULL,(LPBYTE*)&domainName)==NERR_Success) { + wcscpy(w_pdc,domainName); + NetApiBufferFree(domainName); + } + } MultiByteToWideChar(CP_ACP,0,name,-1,w_name,UNLEN+1); } } @@ -419,14 +429,9 @@ res=NetUserGetInfo(w_pdc,w_name,1,(BYTE**)&pinfo); if(res==NERR_UserNotFound) { - if(w_pdc) - NetApiBufferFree(w_pdc); return NULL; } - if(w_pdc) - WideCharToMultiByte(0,0,w_pdc,-1,pdc,sizeof(pdc),0,0); - pw.pw_uid=0; pw.pw_gid=0; pw.pw_name=name; @@ -436,7 +441,13 @@ pw.pw_pdc =w_pdc; pw.pw_name_t = w_name; #else - pw.pw_pdc=w_pdc?pdc:NULL; + if(w_pdc[0]) { + WideCharToMultiByte(0,0,w_pdc,-1,pdc,sizeof(pdc),0,0); + pw.pw_pdc=pdc; + } + else { + pw.pw_pdc=NULL; + } pw.pw_name_t =name; #endif @@ -452,8 +463,6 @@ NetApiBufferFree(pinfo); if(wk_info) NetApiBufferFree(wk_info); - else if(w_pdc) - NetApiBufferFree(w_pdc); return &pw; #else // Win95 broken version. Rely on the HOME environment variable... static struct passwd pw; -- Best regards, Alexey mailto:alexey-panchenko at hotmail.ru