Solved

VBScript: How do I assign a group to another group in Win2K?

Posted on 2004-08-30
2
893 Views
Last Modified: 2009-02-17
L.S.,

I'm working on an automated procedure to implement a security model on a server, like doing user to group assignments, user creation, file system rights, things like that.

There's one thing I can't get done: assigning groups to other groups. I keep getting error 'A new member could not be added to a local group because the member has the wrong account type.'

Here's the code I use:

Sub doAddGroupsToGroup(strDomain, strParentGroup, strNestedGroup)
      Dim objDomain
      Dim objParentGroup
      Dim objNestedGroup
      Set objDomain = GetObject("WinNT://" & strDomain)
      Set objParentGroup = GetObject("WinNT://" & strDomain & "/" & strParentGroup & ",group")
      Set objNestedGroup = GetObject("WinNT://" & strDomain & "/" & strNestedGroup & ",group")
            
      doLog 4, "Adding group '" & objNestedGroup.Name & "' to group '" & objParentGroup.Name & "'..."
      objParentGroup.Add(objNestedGroup.AdsPath)
      
      ' most-common error trapping            
      If (Hex(Err.Number) = 80070562) Then ' user already resides in that group
            doLog 4, "Group '" & objNestedGroup.Name & "' already resides in group '" & objParentGroup.Name & "'."
      Else
            doLog 0, "Group '" & objNestedGroup.Name & "' was added to group '" & objParentGroup.Name & "' successfully."
      End If
              
      Set objGroup = Nothing
      Set objDomain = Nothing
End Sub

Notes:
- the doLog subroutine is a routine that basically does nothing but echo to the console log and log the same thing to a log file.
- I know the error handling is NOT what it should be right now, I'll get to that later...

Thanks for any help! Regards,
Steven Dijkman.
0
Comment
Question by:stevendijkman
2 Comments
 
LVL 1

Accepted Solution

by:
mpantana earned 250 total points
ID: 11933351
In my experience, you can not add a global group to another global group.  You can only add global groups to local groups.  Standard practice is that when you have files on a disk that you want to give access to a global group, you should create a local version of that group first and then add the global group to the local.  Then assign the rights to the local group.
0
 
LVL 3

Expert Comment

by:Julian_C
ID: 11940150
Yes, to confirm the above from mpantana, you should just try this using the MMC snapin (or usrmgr on NT). I don't think it's possible to nest global groups like this so I don't recko the manual method will work either.

Cheers
Julian
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 125
Apps blocked by Java 9 88
Why is enum singleton a better approach than static factory 3 25
batch file or script 4 28
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question