From: Karl E. Peterson on
on 6/16/2010, GS supposed :
> 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...

Not exactly sure where it's going yet, but I'm working on a tool that
will tell me what groups a user belongs to on various domains as well
as locally. Wanted to be able to really identify who was using it due
to the complex nature of the environment.

--
..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
> Not exactly sure where it's going yet, but I'm working on a tool that will
> tell me what groups a user belongs to on various domains as well as locally.
> Wanted to be able to really identify who was using it due to the complex
> nature of the environment.

Sounds like a good tool to have. I saw the link to the sample you
posted and it looks promising as the way to go. I'd be interested to
see what comes of this!

Did you look at Kevin's suggestion for using WScript.Network? Seems
simple enough but I don't know how it would behave in your case. Any
comments to that?

--
Garry

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


From: Karl E. Peterson on
GS used his keyboard to write :
>> Not exactly sure where it's going yet, but I'm working on a tool that will
>> tell me what groups a user belongs to on various domains as well as
>> locally. Wanted to be able to really identify who was using it due to the
>> complex nature of the environment.
>
> Sounds like a good tool to have. I saw the link to the sample you posted and
> it looks promising as the way to go. I'd be interested to see what comes of
> this!

I'll almost certainly post it, sure.

> Did you look at Kevin's suggestion for using WScript.Network? Seems simple
> enough but I don't know how it would behave in your case. Any comments to
> that?

I have a feeling that's just a wrapper around the NetWkstaGetInfo and
NetWkstaUserGetInfo API calls, and they're giving me exactly the info
needed, yep.

--
..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 formulated on Wednesday :
> GS used his keyboard to write :
>>> Not exactly sure where it's going yet, but I'm working on a tool that will
>>> tell me what groups a user belongs to on various domains as well as
>>> locally. Wanted to be able to really identify who was using it due to the
>>> complex nature of the environment.
>>
>> Sounds like a good tool to have. I saw the link to the sample you posted
>> and it looks promising as the way to go. I'd be interested to see what
>> comes of this!
>
> I'll almost certainly post it, sure.
>
>> Did you look at Kevin's suggestion for using WScript.Network? Seems simple
>> enough but I don't know how it would behave in your case. Any comments to
>> that?
>
> I have a feeling that's just a wrapper around the NetWkstaGetInfo and
> NetWkstaUserGetInfo API calls, and they're giving me exactly the info needed,
> yep.

Ok, Karl. Here's what I did with Kevin's example, to add to my arsenal
of DrivesFoldersFiles_Functions.bas:

Function bUserIsLocalLogin() As Boolean
Dim oWS_Network
Set oWS_Network = CreateObject("WScript.Network")
bUserIsLocalLogin = (oWS_Network.UserDomain =
oWS_Network.ComputerName)
End Function

--
Garry

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


From: Karl E. Peterson on
GS used his keyboard to write :
> Karl E. Peterson formulated on Wednesday :
>> GS used his keyboard to write :
>>>> Not exactly sure where it's going yet, but I'm working on a tool that
>>>> will tell me what groups a user belongs to on various domains as well as
>>>> locally. Wanted to be able to really identify who was using it due to
>>>> the complex nature of the environment.
>>>
>>> Sounds like a good tool to have. I saw the link to the sample you posted
>>> and it looks promising as the way to go. I'd be interested to see what
>>> comes of this!
>>
>> I'll almost certainly post it, sure.
>>
>>> Did you look at Kevin's suggestion for using WScript.Network? Seems simple
>>> enough but I don't know how it would behave in your case. Any comments to
>>> that?
>>
>> I have a feeling that's just a wrapper around the NetWkstaGetInfo and
>> NetWkstaUserGetInfo API calls, and they're giving me exactly the info
>> needed, yep.
>
> Ok, Karl. Here's what I did with Kevin's example, to add to my arsenal of
> DrivesFoldersFiles_Functions.bas:
>
> Function bUserIsLocalLogin() As Boolean
> Dim oWS_Network
> Set oWS_Network = CreateObject("WScript.Network")
> bUserIsLocalLogin = (oWS_Network.UserDomain = oWS_Network.ComputerName)
> End Function

That seems to be valid. I'm leary of ever relying on WSH when there's
an API that'll do the job, though. You can achieve those same results
using the NetWksta sample I pointed to earlier.

--
..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