Chris Kowalske
December 1st, 1998, 03:33 PM
I need some sample code to retrieve the Owner of an Exchange Distriution List using either CDO or ADSI. Thanks
Chris Kowalske
Chris Kowalske
|
Click to See Complete Forum and Search --> : DL Owner through CDO or ADSI Chris Kowalske December 1st, 1998, 03:33 PM I need some sample code to retrieve the Owner of an Exchange Distriution List using either CDO or ADSI. Thanks Chris Kowalske Chris Kowalske December 4th, 1998, 10:21 AM For those that care, I found my own answer and maybe it will help you. I tried and tried with CDO, but just couldn't figure out a way to get the Exchange Distribution List owner. I decided that it was time to get my lazy butt into some ADSI coding and starting looking at some sample apps that connected to the Exchange server through LDAP. After about a days worth of goofing around and trying different things, this is what I came up with: First you must make a connection to you Exchange server's Recipients container. Set objRecipients = GetObject("LDAP://" + strServer + "/cn=Recipients,ou=" + strSite + ",o=" + strOrg) Then you need to figure out which Recipients are Distribution Lists. For Each Child In objRecipients If InStr(1, Child.Class, "groupOfNames") Then List1.AddItem Child.cn List2.AddItem Child.distinguishedName End If Next Reason I'm adding both the cn and distinguishedName into list boxes is because List1 is being displayed to the user, so we want the full name shown. List2 is hidden from the user and I use it to store the DN for future LDAP queries. I could have used an array or collection, but I'm lazy :> Now when the user selects a DL in List1 I need to grab the owner of that list. List2.ListIndex = List1.ListIndex Set objChild = GetObject("LDAP://" + strServer + "/" + List2.Text) sOwnerName = GetNameFromDN(objChild.owner) Label1.Caption = "Owner of DL is: " + sOwnerName GetNameFromDN is a function that strips off all the extra chars I don't need. I only needed the owners name which I use to create a mail message and add his name in the to field. I hope this helps someone out there, and I hope maybe it sparks an interest in ADSI to those that were scared. I was one of those scared ones and know that I've messed with it, it really is cool and pretty easy. Chris Kowalske TSG - San Antonio Software Spectrum codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |