VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Connects to Active Directory, Automaticly Establishes your domain and username, requires a group na

by Simon Stearn (1 Submission)
Category: Windows System Services
Compatability: VB Script
Difficulty: Unknown Difficulty
Originally Published: Wed 26th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Connects to Active Directory, Automaticly Establishes your domain and username, requires a group name to be passed, then dose something if the

Rate Connects to Active Directory, Automaticly Establishes your domain and username, requires a group na



'*FileName:    ScriptRunner.vbs
'*ScriptName:  ScriptRunner
'*Created:     25/05/04
'*Author:      Simon Stearn
'*
'*Description: 
'*             Visual Basic Script language, designed
'*             to map users home drive's and shared 
'*             drive's, based on the the groups a user
'*             belongs to in Active Directory, 
'*             This script Uses ADSI
'*
'*Usage: 
'*             If( VerifyGroupMembers( WN.UserDomain, strGroup, WN.UserName ) = True ) Then
'*             Basic If Statment calling Useing ADSI, WN.UserDomain will get the currently 
'*             connected Domain, strGroup needs a Group Name As String passed to it, finaly
'*             WN.UserName will get the currently Logged on/Logging on user
'*      
'*Revision History:
'*             Created 25/05/04 By Simon Stearn
'*
'*
*

Function VerifyGroupMembers( strDomain, strGroup, strUser )
    
    VerifyGroupMembers = False 
    Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup & ",group")

    For Each objUser In objGroup.Members

        bMemberFound = False  

        If strUser = objUser.name then
            bMemberFound = True
            Exit For
        End If
    
     If( Not bMemberFound ) Then
         VerifyGroupMembers = False
     End If
    Next

    VerifyGroupMembers = True
End Function


' ****************************************************************************
' Main
' ****************************************************************************
Set WN = CreateObject("Wscript.Network")


If( VerifyGroupMembers( WN.UserDomain, strGroup, WN.UserName ) = True ) Then
    WScript.Echo "User in Group Need Some Code To Do Some Thing"
Else
    WScript.Echo "Doing nothing, User Not in Group"
WScript.Echo "Member NOT found: " & strUser 'objUser.Name
End If



Download this snippet    Add to My Saved Code

Connects to Active Directory, Automaticly Establishes your domain and username, requires a group na Comments

No comments have been posted about Connects to Active Directory, Automaticly Establishes your domain and username, requires a group na. Why not be the first to post a comment about Connects to Active Directory, Automaticly Establishes your domain and username, requires a group na.

Post your comment

Subject:
Message:
0/1000 characters