I searched this site, as well as Google, but haven't been able to find what I need.
I'm creating a VB.Net program that will create users in our Active Directory and add them to a mailing list we have created.
I have the code for creating the contact down, and that works great. I'll link it below for reference.
What I need to do now is add that new contact to the distribution list, and I am not sure how to accomplish that.
At this point I can open Active Directory and find the new contact.
Does anyone know how to then take this contact and add them to a distribution list? I need to open the Contact and go to the "Member of" tab and see the correct list displayed there.
I'm creating a VB.Net program that will create users in our Active Directory and add them to a mailing list we have created.
I have the code for creating the contact down, and that works great. I'll link it below for reference.
What I need to do now is add that new contact to the distribution list, and I am not sure how to accomplish that.
VB.NET:
[SIZE=2]Dim oRootSam [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DirectoryEntry [/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] New DirectoryEntry[/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][URL]ldap://ou=SAMMONS REPRESENTATIVES,ou=Email Distribution,DC=sigmafin,DC=sigmafinancial,DC=com[/URL][/SIZE][SIZE=2][COLOR=#808080][SIZE=2][COLOR=#808080])
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] newContact [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DirectoryEntry[/COLOR]
newContact = oRootSam.Children.Add(cnName, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Contact"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Set properties[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
newContact.Properties([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"GivenName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).Add(fName)
newContact.Properties([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"sn"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).Add(lName)
newContact.Properties([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"DisplayName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).Add(fName & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & lName)
newContact.Properties([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"mail"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]).Add(email)
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]
'Save the new contact[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
newContact.CommitChanges()
[/SIZE][/SIZE][/COLOR][/SIZE]
At this point I can open Active Directory and find the new contact.
Does anyone know how to then take this contact and add them to a distribution list? I need to open the Contact and go to the "Member of" tab and see the correct list displayed there.