Check "LOGON" User Group 
Author Message
 Check "LOGON" User Group

Dear All,

I am writing a script for check the User Name and assign the network drive
to user. I write the script as following:

Set WshShell = WScript.CreateObject("WScript.Shell")
LOGONUSER=WshShell.ExpandEnvironmentStrings("%USERNAME%")
WScript.Echo LOGONUSER

Set grp = GetObject("WinNT://SERVER1/GROUPNAME")
mem = grp.IsMember("WinNT://SERVER1/USERNAME")
WScript.Echo mem

I can get the Current User name at the FIRST WScript.Echo and compare the
user in group at the end of WScript.Echo  ( 0 or -1 code return). However,
how can I put the variable LOGONUSER to

        mem = grp.IsMember("WinNT://SERVER1/USERNAME")

Thanks and Best Regards,
Alex



Fri, 08 Oct 2004 12:07:25 GMT  
 Check "LOGON" User Group
If I understand your question correctly, the answer is:

    mem = grp.IsMember("WinNT://SERVER1/" & LOGONUSER)

By the way, is there a special reason you are getting the user account from
an environment variable? This was common in the Novell NetWare world, but in
Windows, you can get it from the UserName property of the WScript.Network
object. The advantage is that you can also get the NT Domain name from the
UserDomain property. (Assuming you are not logging into a standalone server
or a member server using a local account, it would be better to use the name
of the domain in your ADSI string instead of the name of a domain
controller. That way, any DC can service the request, providing some measure
of fault tolerance.) If you happen to have Windows 9X clients and your WSH
script is being called from a logon script, you need to loop until UserName
gets a value, because logon scripts can start executing on Windows 9X
clients before Network properties have been initialized.



Fri, 08 Oct 2004 16:03:54 GMT  
 Check "LOGON" User Group
Understood. 1000 Thanks


Quote:
> If I understand your question correctly, the answer is:

>     mem = grp.IsMember("WinNT://SERVER1/" & LOGONUSER)

> By the way, is there a special reason you are getting the user account
from
> an environment variable? This was common in the Novell NetWare world, but
in
> Windows, you can get it from the UserName property of the WScript.Network
> object. The advantage is that you can also get the NT Domain name from the
> UserDomain property. (Assuming you are not logging into a standalone
server
> or a member server using a local account, it would be better to use the
name
> of the domain in your ADSI string instead of the name of a domain
> controller. That way, any DC can service the request, providing some
measure
> of fault tolerance.) If you happen to have Windows 9X clients and your WSH
> script is being called from a logon script, you need to loop until
UserName
> gets a value, because logon scripts can start executing on Windows 9X
> clients before Network properties have been initialized.



Fri, 08 Oct 2004 16:54:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Check "LOGON" Users

2. "add users and groups" interface

3. "add users and groups" interface

4. adding user account to "Users" container

5. adding users to "Users" container

6. Propertie "Allow logon to terminal server"

7. "Allow logon to terminal services" syntax

8. change DPI settings (via "Group Policy"?)

9. "Primary" Group Membership

10. Detecting "Primary Group" Membership

11. Client Side "Check All" script

12. Disabling "BACK"/"FORWARD" buttons

 

 
Powered by phpBB® Forum Software