?
Solved

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

Posted on 2004-08-30
2
Medium Priority
?
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
mpantana earned 750 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

Make the most of your online learning experience.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

719 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