Solved

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

Posted on 2004-08-30
2
896 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 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

632 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