Re: Add all users to a grouop - Help please




"Cmor" <cmor1701d@xxxxxxxxx> wrote in message
news:18491687-32c2-4884-8c3a-668c819ecaee@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I need to all all domain users to a group. I previously wrote a
script that read all the members of Group1 and added them in this new
group. I re-ran the script for Group2 when asked. That took care of
90% of our users. Now I have been asked to add all users to this
group. To the end I wrote the following code. It is not working and
I'm not sure why. As I am not a domain admin I have to get someone
else to run the script. Please let me know where I am going wrong and
what needs to be done to 'add all domain users to groupX".

When you are done you will have two groups with exactly the same members.
"Domain users" will contain all accounts in the domain, and some other group
will contain the same members. If the purpose is to start with a list of all
accounts and remove them as part of an accounting method to ensure that some
process is carried out against each account this might make sense. But if
both groups will always have identical membership, why not just use "domain
users"? If there is some reason why you do not want to do this, you could
simply add the group "domain users" as a member of the other group.

/Al


TIA --

CODE:
Option Explicit
On Error Resume Next
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim objConn, objComm, objRS, objUser, objFSO, oLogFile
Dim strBase, strFilter, strAttrs, strScope, strUser, objNewGroup
'**********************************************************************
'Set the ADO search criteria
'**********************************************************************
strBase = "<LDAP://dc=mydomain,dc=com>;"
strFilter = "(&(objectclass=user)(objectcategory=person));"
strAttrs = "ADsPath;"
strScope = "Subtree"

Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set oLogFile = objFSO.OpenTextFile ("M:\scripts\DNS
\DWA_All_GROUP_Report.txt", ForWriting, True)
oLogFile.WriteLine vbTab & "DWA Group Changes made on: " & Now

set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open
Set objComm = CreateObject("ADODB.Command")
Set objComm.ActiveConnection = objConn
objComm.CommandText = strBase & strFilter & strAttrs & strScope
objComm.Properties("Page Size") = 1000
Set objNewGroup = GetObject("LDAP://
CN=DWA,OU=No5,OU=No4,OU=No3,OU=No2,OU=Departments,DC=mydomain,DC=com")
Set objRS = objComm.Execute()
While not objRS.EOF
Set objUser = GetObject( objRS.Fields.Item("ADsPath").Value )
objNewGroup.Add "LDAP://"; & objUser.distinguishedName
objNewGroup.SetInfo
If Err.Number <> 0 Then
oLogFile.WriteLine vbTab & objUser.name & " Already exists"
Else
oLogFile.WriteLine vbTab & objUser.name & " Added"
End If
objRS.MoveNext
Wend
oLogFile.Close
WScript.Quit


.



Relevant Pages

  • Re: users have gray hair in Domain Users group
    ... The members of domain users group in both of the tree domains have ... when I use the below script to enumerate the membership of the ... domain users group in each of the domains, ... any reasons why I cannot enumerate the Domain Local group? ...
    (microsoft.public.win2000.active_directory)
  • Re: Add all users to a grouop - Help please
    ... I need to all all domain users to a group. ... script that read all the members of Group1 and added them in this new ... I re-ran the script for Group2 when asked. ... IsMember and Add methods of the group object. ...
    (microsoft.public.scripting.vbscript)
  • Re: users have gray hair in Domain Users group
    ... The members of domain users group in both of the tree domains have ... when I use the below script to enumerate the membership of the ... domain users group in each of the domains, ... any reasons why I cannot enumerate the Domain Local group? ...
    (microsoft.public.win2000.active_directory)
  • Re: Add all users to a grouop - Help please
    ... Though there are very few times where you will need 2 groups with the same members, it is not very good to do so. ... Other than writing a complicated script, you can do a few other things to get it done. ... I need to all all domain users to a group. ... If the purpose is to start with a list of all accounts and remove them as part of an accounting method to ensure that some process is carried out against each account this might make sense. ...
    (microsoft.public.scripting.vbscript)
  • Re: Prevent Users interactive login, but allow them to run batch j
    ... That user is member of "Domain Users" group. ... on Locally) But the second setting "Log on as batch job" has no effect. ... but that the account needs something else. ... Domain Users as well as Authenticated Users are made members ...
    (microsoft.public.win2000.security)