From: Gurusamy Sarathy Date: Mon, 9 Mar 1998 20:56:07 +0000 (+0000) Subject: [win32] tweak Win32::DomainName() implementation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a2408cf95e2553965bca3db04584ae3d4927326;p=p5sagit%2Fp5-mst-13.2.git [win32] tweak Win32::DomainName() implementation p4raw-id: //depot/win32/perl@803 --- diff --git a/win32/Makefile b/win32/Makefile index 2653920..54ce192 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -186,7 +186,6 @@ X2P=..\x2p\a2p.exe PL2BAT=bin\pl2bat.pl GLOBBAT = bin\perlglob.bat -MAKE=nmake -nologo CFGSH_TMPL = config.vc CFGH_TMPL = config_H.vc PERL95EXE=..\perl95.exe @@ -421,8 +420,7 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl $(XCOPY) ..\*.h $(COREDIR)\*.* $(XCOPY) *.h $(COREDIR)\*.* $(RCOPY) include $(COREDIR)\*.* - $(MINIPERL) -I..\lib config_h.PL || $(MAKE) CCTYPE=$(CCTYPE) \ - RUNTIME=$(RUNTIME) CFG=$(CFG) $(CONFIGPM) + $(MINIPERL) -I..\lib config_h.PL || $(MAKE) $(MAKEFLAGS) $(CONFIGPM) $(MINIPERL) : ..\miniperlmain$(o) $(CORE_OBJ) $(WIN32_OBJ) $(LINK32) -subsystem:console -out:$@ @<< diff --git a/win32/win32.c b/win32/win32.c index aaf5139..e1192f8 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1910,31 +1910,21 @@ static XS(w32_DomainName) { dXSARGS; -#if 0 - /* doesn't do the right thing if current user is a local account */ - char name[256]; - DWORD size = sizeof(name); - if (GetUserName(name,&size)) { - char sid[1024]; - DWORD sidlen = sizeof(sid); - char dname[256]; - DWORD dnamelen = sizeof(dname); - SID_NAME_USE snu; - if (LookupAccountName(NULL, name, &sid, &sidlen, - dname, &dnamelen, &snu)) { - XSRETURN_PV(dname); /* all that for this */ - } - } -#else char dname[256]; DWORD dnamelen = sizeof(dname); - WKSTA_INFO_100 wi; - if (NERR_Success == NetWkstaGetInfo(NULL, 100, (LPBYTE*)&wi)) { - WideCharToMultiByte(CP_ACP, NULL, wi.wki100_langroup, -1, - (LPSTR)dname, dnamelen, NULL, NULL); + PWKSTA_INFO_100 pwi; + if (NERR_Success == NetWkstaGetInfo(NULL, 100, (LPBYTE*)&pwi)) { + if (pwi->wki100_langroup && *(pwi->wki100_langroup)) { + WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup, + -1, (LPSTR)dname, dnamelen, NULL, NULL); + } + else { + WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername, + -1, (LPSTR)dname, dnamelen, NULL, NULL); + } + NetApiBufferFree(pwi); XSRETURN_PV(dname); } -#endif XSRETURN_UNDEF; }