[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB script to update distribution list

Posted on 2009-02-23
6
Medium Priority
?
684 Views
Last Modified: 2012-06-22
Need a VB script which will update "XYZ" distribution list membership from the related security group. All members (users and groups) of the distribution group are removed first.Then the related security group is fully expanded to include all members (users and groups). Finally, the members (users and groups) are added from the related security group
0
Comment
Question by:mahesh_gowda
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:kjanicke
ID: 23711074
Couldn't you just mail enable the security group, and use one group for both purposes?
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 23711102

Depending on your aim, it could be as simple as this. It simply overwrites the membership of the Destination Group with that from the Source Group.

Chris

Set objSourceGroup = GetObject("LDAP://CN=Source Group Name,OU=somewhere,DC=yourdomain,DC=com")
Set objDestGroup = GetObject("LDAP://CN=Dest Group Name,OU=somewhere,DC=yourdomain,DC=com")
 
objDestGroup.Put "member", objSourceGroup.GetEx("member")
objDestGroup.SetInfo

Open in new window

0
 

Author Comment

by:mahesh_gowda
ID: 23712825
Hello Sage,
                    Thank you for your reply. We need to remove the member and we want the security group to expand fully to include all members. Can you let me know on this.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 71

Expert Comment

by:Chris Dent
ID: 23712840

What do you mean by expand fully to include all members?

The above already removes existing members, simply because it completely overwrites any current membership.

Chris
0
 

Author Comment

by:mahesh_gowda
ID: 23712917
Hello Chris,
                  Thank you!!  Is there a possibility for us to get a mail once the update is done? Can you help me on that?
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 150 total points
ID: 23713018

Sure, if you like.

You'll need to make some changes, hopefully it should be obvious enough where :)

Chris

Set objSourceGroup = GetObject("LDAP://CN=Source Group Name,OU=somewhere,DC=yourdomain,DC=com")
Set objDestGroup = GetObject("LDAP://CN=Dest Group Name,OU=somewhere,DC=yourdomain,DC=com")
 
objDestGroup.Put "member", objSourceGroup.GetEx("member")
objDestGroup.SetInfo
 
Set objSourceGroup = Nothing
 
Set objMail = CreateObject("CDO.Message")
 
' SMTP server
strServer = "yourmailserver"
 
' To / From and Subject for the message
objMail.To = "someone@yourdomain.com"
objMail.From = "someone@somewhere.com"
objMail.Subject = "Group Update"
 
' Message Body
' Just e-mails a list of current members
objMail.TextBody = "Updated group membership for " & objDstGroup.Get("name") & vbCrLf & vbCrLf & _
  "Members:" & vbCrLf & Join(objDestGroup.GetEx("member"), vbCrLf)
 
objMail.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer
objMail.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 
objMail.Configuration.Fields.Update
objMail.Send
Set objMail = Nothing
 
Set objDestGroup = Nothing

Open in new window

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

834 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