 |
|
 |
|
Next: Multiple IP Change Script
|
| Author |
Message |
External

Since: Sep 10, 2003 Posts: 1
|
(Msg. 1) Posted: Wed Sep 10, 2003 4:44 pm
Post subject: List of groups Archived from groups: microsoft>public>windows>server>scripting (more info?)
|
|
|
Hello!
I'm having trouble to display list of groups from dictionary object for this
script: Logon3.vbs by Richard L. Mueller. Can anybody help me?
Grega
' Logon3.vbs
' VBScript logon script program.
'
' ----------------------------------------------------------------------
' Copyright (c) 2002 Richard L. Mueller
' Version 1.0 - November 22, 2002
' Version 1.1 - February 19, 2003 - Standardize Hungarian notation.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty, obligations,
' or liability for such use.
Option Explicit
Dim objNetwork, objSysInfo, strUserDN
Dim objGroupList, objUser, objFSO
Dim strComputerDN, objComputer
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.userName
strComputerDN = objSysInfo.computerName
' Bind to the user and computer objects with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
Set objComputer = GetObject("LDAP://" & strComputerDN)
' Map a network drive if the user is a member of the group.
' Alert the user if the drive cannot be mapped.
If IsMember(objUser, "Engineering") Then
If Not MapDrive("M:", "\\FileServer\EngrShare") Then
MsgBox "Unable to Map M: to AdminShare"
End If
End If
' Add a network printer if the computer is a member of the group.
' Make this printer the default.
If IsMember(objComputer, "Front Office") Then
objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLaser2"
objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2"
End If
' Clean up.
Set objNetwork = Nothing
Set objFSO = Nothing
Set objSysInfo = Nothing
Set objGroupList = Nothing
Set objUser = Nothing
Set objComputer = Nothing
Function IsMember(objADObject, strGroup)
' Function to test for group membership.
' objGroupList is a dictionary object with global scope.
If IsEmpty(objGroupList) Then
Set objGroupList = CreateObject("Scripting.Dictionary")
End If
If Not objGroupList.Exists(objADObject.sAMAccountName & "\") Then
Call LoadGroups(objADObject, objADObject)
objGroupList(objADObject.sAMAccountName & "\") = True
End If
IsMember = objGroupList.Exists(objADObject.sAMAccountName & "\" _
& strGroup)
End Function
Sub LoadGroups(objPriObject, objADSubObject)
' Recursive subroutine to populate dictionary object objGroupList.
Dim colstrGroups, objGroup, j
objGroupList.CompareMode = vbTextCompare
colstrGroups = objADSubObject.memberOf
If IsEmpty(colstrGroups) Then
Exit Sub
End If
If TypeName(colstrGroups) = "String" Then
Set objGroup = GetObject("LDAP://" & colstrGroups)
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Set objGroup = Nothing
Exit Sub
End If
For j = 0 To UBound(colstrGroups)
Set objGroup = GetObject("LDAP://" & colstrGroups(j))
If Not objGroupList.Exists(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) Then
objGroupList(objPriObject.sAMAccountName & "\" _
& objGroup.sAMAccountName) = True
Call LoadGroups(objPriObject, objGroup)
End If
Next
Set objGroup = Nothing
End Sub
Function MapDrive(strDrive, strShare)
' Function to map network share to a drive letter.
' If the drive letter specified is already in use, the function
' attempts to remove the network connection.
' objFSO is the File System Object, with global scope.
' objNetwork is the Network object, with global scope.
' Returns True if drive mapped, False otherwise.
Dim objDrive
On Error Resume Next
Err.Clear
If objFSO.DriveExists(strDrive) Then
Set objDrive = objFSO.GetDrive(strDrive)
If Err.Number <> 0 Then
Err.Clear
MapDrive = False
Exit Function
End If
If CBool(objDrive.DriveType = 3) Then
objNetwork.RemoveNetworkDrive strDrive, True, True
Else
MapDrive = False
Exit Function
End If
Set objDrive = Nothing
End If
objNetwork.MapNetworkDrive strDrive, strShare
If Err.Number = 0 Then
MapDrive = True
Else
Err.Clear
MapDrive = False
End If
On Error GoTo 0
End Function >> Stay informed about: List of groups |
|
| Back to top |
|
 |  |
External

Since: Sep 09, 2003 Posts: 9
|
(Msg. 2) Posted: Wed Sep 10, 2003 4:44 pm
Post subject: List of groups [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
What error are you getting? One thing you can change is
the printer section change objComputer to objuser. I had
a problem with the script not working and this was the
change I made which then started working.
>' Make this printer the default.
>If IsMember(objComputer, "Front Office") Then
>
objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLas
er2"
> objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2"
>End If
Change that section to be this
>' Make this printer the default.
>If IsMember(objUser, "Front Office") Then
>
objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLas
er2"
> objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2"
>End If
>-----Original Message-----
>Hello!
>
>I'm having trouble to display list of groups from
dictionary object for this
>script: Logon3.vbs by Richard L. Mueller. Can anybody
help me?
>
>Grega
>' Logon3.vbs
>' VBScript logon script program.
>'
>' --------------------------------------------------------
--------------
>' Copyright (c) 2002 Richard L. Mueller
>' Version 1.0 - November 22, 2002
>' Version 1.1 - February 19, 2003 - Standardize Hungarian
notation.
>'
>' You have a royalty-free right to use, modify,
reproduce, and
>' distribute this script file in any way you find useful,
provided that
>' you agree that the copyright owner above has no
warranty, obligations,
>' or liability for such use.
>
>Option Explicit
>
>Dim objNetwork, objSysInfo, strUserDN
>Dim objGroupList, objUser, objFSO
>Dim strComputerDN, objComputer
>
>Set objNetwork = CreateObject("Wscript.Network")
>Set objFSO = CreateObject("Scripting.FileSystemObject")
>Set objSysInfo = CreateObject("ADSystemInfo")
>strUserDN = objSysInfo.userName
>strComputerDN = objSysInfo.computerName
>
>' Bind to the user and computer objects with the LDAP
provider.
>Set objUser = GetObject("LDAP://" & strUserDN)
>Set objComputer = GetObject("LDAP://" & strComputerDN)
>
>' Map a network drive if the user is a member of the
group.
>' Alert the user if the drive cannot be mapped.
>If IsMember(objUser, "Engineering") Then
> If Not MapDrive("M:", "\\FileServer\EngrShare") Then
> MsgBox "Unable to Map M: to AdminShare"
> End If
>End If
>
>' Add a network printer if the computer is a member of
the group.
>' Make this printer the default.
>If IsMember(objComputer, "Front Office") Then
>
objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLas
er2"
> objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2"
>End If
>
>' Clean up.
>Set objNetwork = Nothing
>Set objFSO = Nothing
>Set objSysInfo = Nothing
>Set objGroupList = Nothing
>Set objUser = Nothing
>Set objComputer = Nothing
>
>Function IsMember(objADObject, strGroup)
>' Function to test for group membership.
>' objGroupList is a dictionary object with global scope.
>
> If IsEmpty(objGroupList) Then
> Set objGroupList = CreateObject
("Scripting.Dictionary")
> End If
> If Not objGroupList.Exists(objADObject.sAMAccountName
& "\") Then
> Call LoadGroups(objADObject, objADObject)
> objGroupList(objADObject.sAMAccountName & "\") = True
> End If
> IsMember = objGroupList.Exists
(objADObject.sAMAccountName & "\" _
> & strGroup)
>End Function
>
>Sub LoadGroups(objPriObject, objADSubObject)
>' Recursive subroutine to populate dictionary object
objGroupList.
>
> Dim colstrGroups, objGroup, j
>
> objGroupList.CompareMode = vbTextCompare
> colstrGroups = objADSubObject.memberOf
> If IsEmpty(colstrGroups) Then
> Exit Sub
> End If
> If TypeName(colstrGroups) = "String" Then
> Set objGroup = GetObject("LDAP://" & colstrGroups)
> If Not objGroupList.Exists
(objPriObject.sAMAccountName & "\" _
> & objGroup.sAMAccountName) Then
> objGroupList(objPriObject.sAMAccountName & "\" _
> & objGroup.sAMAccountName) = True
> Call LoadGroups(objPriObject, objGroup)
> End If
> Set objGroup = Nothing
> Exit Sub
> End If
> For j = 0 To UBound(colstrGroups)
> Set objGroup = GetObject("LDAP://" & colstrGroups(j))
> If Not objGroupList.Exists
(objPriObject.sAMAccountName & "\" _
> & objGroup.sAMAccountName) Then
> objGroupList(objPriObject.sAMAccountName & "\" _
> & objGroup.sAMAccountName) = True
> Call LoadGroups(objPriObject, objGroup)
> End If
> Next
> Set objGroup = Nothing
>End Sub
>
>Function MapDrive(strDrive, strShare)
>' Function to map network share to a drive letter.
>' If the drive letter specified is already in use, the
function
>' attempts to remove the network connection.
>' objFSO is the File System Object, with global scope.
>' objNetwork is the Network object, with global scope.
>' Returns True if drive mapped, False otherwise.
>
> Dim objDrive
>
> On Error Resume Next
> Err.Clear
> If objFSO.DriveExists(strDrive) Then
> Set objDrive = objFSO.GetDrive(strDrive)
> If Err.Number <> 0 Then
> Err.Clear
> MapDrive = False
> Exit Function
> End If
> If CBool(objDrive.DriveType = 3) Then
> objNetwork.RemoveNetworkDrive strDrive, True, True
> Else
> MapDrive = False
> Exit Function
> End If
> Set objDrive = Nothing
> End If
> objNetwork.MapNetworkDrive strDrive, strShare
> If Err.Number = 0 Then
> MapDrive = True
> Else
> Err.Clear
> MapDrive = False
> End If
> On Error GoTo 0
>End Function
>
>
>.
> >> Stay informed about: List of groups |
|
| Back to top |
|
 |  |
| Related Topics: | Listing groups and users from folders - I need help in creating a script that can list all the user and group memberships of a given folder. This wll also apply to subfolders beneath the root folder. Info needs to be extracted to a file. Thanks, Randolph
tool to enumerate users , groups, shares + ntfs on windows.. - I have seen some tools to list users, and groups but i need a tool to list all the ntfs permissions, shares, local groups on member servers, and global groups etc domain wide. thanks
List of Local/Domain grp members - Hi Experts, appr if you are able to help. I am in need of a tool that can help me to list all members in a grp. My servers are NT 4 & WIn2k. TQ
Generate a list of folders with sizes - Does anyone know of a script/tool for generating a list of folders on an NT 4.0 server with the size of each folder? I would like to get an idea of which folders are taking up the most space on the server. Many thanks for any help. Brian |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|