ADSI 
Author Message
 ADSI

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
{*filter*}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



Fri, 19 Jul 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ADSI

2. ADSI Help

3. Creating user in AD with ADSI

4. help With ADSI

5. ADSI and .Net

6. NTFS and ADSI

7. Creating NT User accounts using ADSI (WinNT:) within VB.Net

8. VB.Net - ADSI property name with dashes

9. ADSI

10. ADSI and VB.NET

11. Create a new IIS site using ADSI

12. ADSI & VB.Net

 

 
Powered by phpBB® Forum Software