Testing for NT Group membership within VB Script 
Author Message
 Testing for NT Group membership within VB Script

Win32 Scripting [Clarence Washington]
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/
http://www.*-*-*.com/

Check the ADSI FAQ...

http://www.*-*-*.com/

There are also lots of logon script examples in the repository...

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> I am writing a network logon script and want to test if the person
> logging on is a member of an NT security group, and map their network
> drives accordingly.  I know in a batch file I could use the ifmember
> utility that comes with the NT resource kit, but I am trying to find a
> way of doing the same thing within a .vbs.  Any suggestions?

> Thanks

> Richard



Sun, 02 Mar 2003 03:00:00 GMT  
 Testing for NT Group membership within VB Script

I am writing a network logon script and want to test if the person
logging on is a member of an NT security group, and map their network
drives accordingly.  I know in a batch file I could use the ifmember
utility that comes with the NT resource kit, but I am trying to find a
way of doing the same thing within a .vbs.  Any suggestions?

Thanks

Richard



Sun, 02 Mar 2003 21:13:32 GMT  
 Testing for NT Group membership within VB Script

I just wrote a small script (function) That test if the current user
is a member of the local administrators group, and returns a true or
false .

I hope I'll help you .
                       Enjoy Ido

Here is the script :

-----------------------------------------------
set WshShell = wscript.createobject("wscript.shell")
Set Fso = CreateObject("Scripting.FileSystemObject")

IfIsAdmin() = True Then
msgbox "The Current User : "+Username+ " Has local Admin Privlige"
End If

Function IsAdmin()
Dim Outfile ,Line ,Retcode
on Error Resume Next

Const ForReading = 1, ForWriting = 2
temp = wshshell.expandenvironmentstrings("%TEMP%")
Username = wshshell.expandenvironmentstrings("%USERNAME%")

Username = LCase(Username)
Retcode = WshShell.run("cmd.exe /c %windir%\system32\net localgroup
administrators > %temp%\192837465.ini 2>&1", 0, True)
Set OutFile = Fso.OpenTextFile(temp+"\192837465.ini", ForReading)

Do While OutFile.AtEndOfStream <> True
    Line = OutFile.ReadLine
         Trim(Line)
        Line = LCase(Line)
        If Line = Username then
        IsAdmin = True
        Exit Do
        End If
  Loop
  If IsAdmin <> True Then
  IsAdmin = False
  End If
OutFile.Close
fso.DeleteFile(temp+"\192837465.ini")
End Function

-----------------------------------------------------------

<Testing for NT Group membership within VB Script>:

I am writing a network logon script and want to test if the person
logging on is a member of an NT security group, and map their network
drives accordingly.  I know in a batch file I could use the ifmember
utility that comes with the NT resource kit, but I am trying to find a
way of doing the same thing within a .vbs.  Any suggestions?

Thanks

Richard



Wed, 05 Mar 2003 03:00:00 GMT  
 Testing for NT Group membership within VB Script


Quote:
>I am writing a network logon script and want to test if the person logging

on is a member of an NT security >group, and map their network drives
accordingly.  I know in a batch file I could use the ifmember utility that
Quote:
>comes with the NT resource kit, but I am trying to find a way of doing the

same thing within a .vbs.  Any >suggestions?

KIX has a membership checking method, and makes for a pretty good logon
script langauge. But if you really want to use VBScript, you can use the
ADSI IsMemberOf method



Thu, 06 Mar 2003 03:00:00 GMT  
 Testing for NT Group membership within VB Script

If you have ADSI installed, you can use this:

Function IsAdmin(strDomain, strUser)
  on error resume next
  IsAdmin = False

  Set GroupObj=GetObject("WinNT://" & strDomain & "/Domain Admins")
  IsAdmin=GroupObj.IsMember("WinNT://" & strDomain & "/" & strUser)

End Function

<Testing for NT Group membership within VB Script>:

I am writing a network logon script and want to test if the person
logging on is a member of an NT security group, and map their network
drives accordingly.  I know in a batch file I could use the ifmember
utility that comes with the NT resource kit, but I am trying to find a
way of doing the same thing within a .vbs.  Any suggestions?

Thanks

Richard



Sun, 09 Mar 2003 00:11:22 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Testing NT 4 Group Membership

2. Testing for membership in NT Security Groups

3. VBScript NT Login Script - checking for group membership

4. VBScript and NT Login Scripts - Group membership?

5. How do I programatically modify a User's NT Group membership in VB

6. Want to test user's security group membership in Access

7. Anybody have a snippet to test Group Membership

8. Group Membership Testing without ADSI?

9. Obtaining Users Group Membership from NT

10. Verifying NT Username and Group Membership

11. NT group membership

12. NT group membership variable

 

 
Powered by phpBB® Forum Software