List Info

Thread: RE: Not every PC is in a named domain




RE: Not every PC is in a named domain
user name
2007-09-20 03:50:35
Steve Hay wrote:
> Jan Dubois wrote:
>> On Mon, 17 Sep 2007, Jerry D. Hedden wrote:
>>> Jan Dubois wrote:
>>>> That is weird, why does the test fail then.
 Doesn't
>>>> Win32:omainNam
e() on that machine return "MSHOME"?  When I run
it
>>>> on an XP (SP2) machine that is not part of
the domain, I get the
>>>> workgroup name: 
>>>> 
>>>>     C:>perl -MWin32 -e "print
Win32:omainNam
e"
>>>>     WORKGROUP
>>> 
>>> It prints out nothing on my PC.  So it appears
to be returning an
>>> empty string.
>> 
>> It looks like we cannot determine the workgroup
name if the
>> "Workstation" service isn't running.  I
therefore removed the
>> Win32:omainNam
e() test from t/Names.t (patch below is against by
>> local depot for the CPAN version, but should
otherwise be identical
>> to the bleadperl one). 
> 
> Couldn't we call Win32:omainNam
e() and then check the value of $^E
> afterwards? If it is 2138 (The Workstation service has
not been
> started) then skip the tests, otherwise test the
returned $domain?

Well, it seems that Win32:omainNam
e() doesn't set $^E to anything
useful on failure, probably because the NetWkstaGetInfo()
API call that
it uses seems to *return* an error code rather than just
returning
true/false and then setting the "last error code"
(which is what $^E
exposes).

The attached patch picks up NetWkstaGetInfo()'s return value
and makes
it the last error code in the event of failure (many Win32
API calls
don't bother setting the last error code when they succeed,
so I haven't
bothered with the "success" case eitehr). The
Names.t script is now able
to test $^E, and correctly skips the DomainName() test for
me if I run
it with the Workstation service stopped.

Does this work for you?

  
RE: Not every PC is in a named domain
user name
2007-09-20 15:25:07
On Thu, 20 Sep 2007, Steve Hay wrote:
> The attached patch picks up NetWkstaGetInfo()'s return
value and makes
> it the last error code in the event of failure (many
Win32 API calls
> don't bother setting the last error code when they
succeed, so I
> haven't bothered with the "success" case
eitehr). The Names.t script
> is now able to test $^E, and correctly skips the
DomainName() test for
> me if I run it with the Workstation service stopped.
>
> Does this work for you?

Yes, it is almost the same as what I already did myself. 
I've applied
your patch instead now.

I'll still make another Win32 release later that you should
integrate
(I've added a note to the docs, and fixed an issue with
t/Names.t and
Vista).

Cheers,
-Jan


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )