From: Karl E. Peterson on
Is there a definitive test for whether the current user on a machine is
operating under a local account or a domain account? I can see
numerous ways to infer such a distinction, but nothing (in the API
realm) that directly tells you this unambiguously.

I suppose the LOGONSERVER environment variable is a pretty good
indication? But I tend not to trust e-vars, in particular with console
utilities. And if I call NetUserGetInfo, the logon server always comes
back "\\*" as opposed to the DC that I actually validated against.

For a number of other reasons, I really don't want to rely on e-vars at
all. Someone suggested if I compared LOGONSERVER with COMPUTERNAME,
that'd be "good enough." But imagine this scenario, and the results if
a console utility found itself there:

C:\>set log
LOGONSERVER=\\NT12

C:\>set logonserver=\\BiteMe

C:\>set log
LOGONSERVER=\\BiteMe

C:\>

I also see that if I call NetUserGetGroups on a local account, it
returns exactly 1 group, and it's name is "None" -- can that be
considered a *definitive* test for a local account?

There's gotta be something very straight-forward here, that I'm simply
not seeing. Right?

Thanks... Karl

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: GS on
Karl E. Peterson explained on 6/16/2010 :
> Is there a definitive test for whether the current user on a machine is
> operating under a local account or a domain account? I can see numerous ways
> to infer such a distinction, but nothing (in the API realm) that directly
> tells you this unambiguously.
>
> I suppose the LOGONSERVER environment variable is a pretty good indication?
> But I tend not to trust e-vars, in particular with console utilities. And if
> I call NetUserGetInfo, the logon server always comes back "\\*" as opposed to
> the DC that I actually validated against.
>
> For a number of other reasons, I really don't want to rely on e-vars at all.
> Someone suggested if I compared LOGONSERVER with COMPUTERNAME, that'd be
> "good enough." But imagine this scenario, and the results if a console
> utility found itself there:
>
> C:\>set log
> LOGONSERVER=\\NT12
>
> C:\>set logonserver=\\BiteMe
>
> C:\>set log
> LOGONSERVER=\\BiteMe
>
> C:\>
>
> I also see that if I call NetUserGetGroups on a local account, it returns
> exactly 1 group, and it's name is "None" -- can that be considered a
> *definitive* test for a local account?
>
> There's gotta be something very straight-forward here, that I'm simply not
> seeing. Right?
>
> Thanks... Karl

Well, this could have a number of scenarios now couldn't it? I'm
guessing you're trying to distinguish between a user logged onto a
domain terminal as a 'local log-in', being different than a log-in
required when they want to access the network server. That's something
I've never had an issue with but I can easily imagine a need to know
since it's quite common (usually for convenience/productivity) for
local log-ins to be the same as domain log-ins, and so how would you
differentiate?

I can't offer any suggestions, Karl, but I'll be interested to see any
solutions that materialize! Good luck...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: C. Kevin Provance on

"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:hvbgnq$nsi$1(a)news.eternal-september.org...
: Is there a definitive test for whether the current user on a machine is
: operating under a local account or a domain account? I can see
: numerous ways to infer such a distinction, but nothing (in the API
: realm) that directly tells you this unambiguously.
:

Hmmmm

If you used the API NetWkstaUserGetInfo (which returns the local networks
domain name), would that give any kind of clue? Or am I not understanding
the situation correctly?


--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk! Paulie want a dingleball, bawwk!

From: C. Kevin Provance on
"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:hvbgnq$nsi$1(a)news.eternal-september.org...
: Is there a definitive test for whether the current user on a machine is
: operating under a local account or a domain account? I can see
: numerous ways to infer such a distinction, but nothing (in the API
: realm) that directly tells you this unambiguously.

I found this on the net. I don't have to point out the obvious caveat.

dim o_wsh_network

set o_wsh_network = createobject( "WScript.Network" )

if o_wsh_network.userdomain = o_wsh_network.computername then
msgbox( "local account" )
else
msgbox( "domain account" )
endif


--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk! Paulie want a dingleball, bawwk!

From: Karl E. Peterson on
C. Kevin Provance explained on 6/16/2010 :
> "Karl E. Peterson" <karl(a)exmvps.org> wrote in message
> news:hvbgnq$nsi$1(a)news.eternal-september.org...
>> Is there a definitive test for whether the current user on a machine is
>> operating under a local account or a domain account? I can see
>> numerous ways to infer such a distinction, but nothing (in the API
>> realm) that directly tells you this unambiguously.
>>
>
> Hmmmm
>
> If you used the API NetWkstaUserGetInfo (which returns the local networks
> domain name), would that give any kind of clue? Or am I not understanding
> the situation correctly?

D'oh!!! Of course. http://vb.mvps.org/samples/NetWksta/

Private Type WKSTA_USER_INFO_1
wkui1_username As Long
wkui1_logon_domain As Long
wkui1_oth_domains As Long
wkui1_logon_server As Long
End Type

In this case, wkui1_logon_domain = wkui1_logon_server, and also...

Private Type WKSTA_INFO_102
wki102_platform_id As Long
wki102_computername As Long
wki102_langroup As Long
wki102_ver_major As Long
wki102_ver_minor As Long
wki102_lanroot As Long
wki102_logged_on_users As Long
End Type

equal to wki102_computername! Even though wki102_langroup identifies
the actual domain to which the machine belongs.

Appreciate the appropriate *kick* in the right direction!

Thanks...

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org