From: C. Kevin Provance on
"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:hvblj4$189$1(a)news.eternal-september.org...
:
: 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...

Always happy to return the favour. <g>



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

This works in all the scenarios I can envision:

Public Function CurrentUserLocal() As Boolean
'http://vb.mvps.org/samples/NetWksta/
Dim Wksta As CNetWksta
' Determine currently logged on user.
Set Wksta = New CNetWksta
CurrentUserLocal = _
(StrComp(Wksta.LogonDomain, Wksta.Domain, vbTextCompare) <> 0)
End Function

That includes:

* Logged in as domain user on domain machine
* Logged in as local user on domain machine
* Logged in as local user on worgroup machine

Did I miss anything? I used the case-insensitive StrComp on the
unlikely(?) possibility of that meaningless (in this context)
difference being the deciding factor.

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

Yeah, I tend to agree with that logic myself, though I do know entire
stand-alone apps are built using only WSH. Fact is, my VBA experience
has conditioned me to using 'wrappers' for most API uses. That extends
also to WSH and other 'convenient' OS components. What concerns me is
the size my many WinAPI declarations adds to projects. I know I can
break them down into encapsulated components easily, and so I should do
more of now that my focus is toward learning how to be a better VB6
programmer. That said, studying the many samples of yours that I have
downloaded from your website encourages me on in that it appears we can
code for just about anything. I just need to get to that place some
day!<g>

I will look at the NetWksta sample I downloaded.
Looking forward to seeing your new tool...

--
Garry

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


From: GS on
Karl E. Peterson explained on 6/16/2010 :
> on 6/16/2010, Karl E. Peterson supposed :
>> 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.
>
> This works in all the scenarios I can envision:
>
> Public Function CurrentUserLocal() As Boolean
> 'http://vb.mvps.org/samples/NetWksta/
> Dim Wksta As CNetWksta
> ' Determine currently logged on user.
> Set Wksta = New CNetWksta
> CurrentUserLocal = _
> (StrComp(Wksta.LogonDomain, Wksta.Domain, vbTextCompare) <> 0)
> End Function
>
> That includes:
>
> * Logged in as domain user on domain machine
> * Logged in as local user on domain machine
> * Logged in as local user on worgroup machine
>
> Did I miss anything? I used the case-insensitive StrComp on the unlikely(?)
> possibility of that meaningless (in this context) difference being the
> deciding factor.

Well, I was particularly interested in the Workgroup part, feeling that
this might be an issue with my WSH function not being able to determine
a domain or workgroup. What say you?

--
Garry

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


From: Karl E. Peterson on
GS laid this down on his screen :
>> 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.
>
> Yeah, I tend to agree with that logic myself, though I do know entire
> stand-alone apps are built using only WSH. Fact is, my VBA experience has
> conditioned me to using 'wrappers' for most API uses. That extends also to
> WSH and other 'convenient' OS components. What concerns me is the size my
> many WinAPI declarations adds to projects. I know I can break them down into
> encapsulated components easily, and so I should do more of now that my focus
> is toward learning how to be a better VB6 programmer. That said, studying the
> many samples of yours that I have downloaded from your website encourages me
> on in that it appears we can code for just about anything. I just need to get
> to that place some day!<g>

You can. The problem is realizing it. <g> See, I *had* the code I
needed sitting right there on the shelf. I just hadn't realized it
yet. Jeeeeez...

> I will look at the NetWksta sample I downloaded.
> Looking forward to seeing your new tool...

Warning! That appears to have been written in 1997!!! I might just
take this opportunity to <ahem> "refresh" it a bit. We'll see... :-)

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