Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 17th, 2012, 06:25 PM
kshahborr1 kshahborr1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 31 kshahborr1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 56 m 5 sec
Reputation Power: 2
Extracting Email Addresses from a Email Distribution List

Hi,

I have the code below which works fine for extracting the email addresses from a distribution group.

The issue is when it tries to recursively get the email and finds a list which has no users or is deactivated it fails there with error :

Active Directory : The directory property cannot be found in the cache.

I want to make sure that it continues after this as well.

Any help pls


strDistListName = "MyDistributionList"

' Get Domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("DefaultNamingContext")

'WScript.Echo "Connecting to: " & strDomain

Set ADOconn = CreateObject("ADODB.Connection")
ADOconn.Provider = "ADSDSOObject"
ADOconn.Open "ADs Provider"
bstrADOQueryString = "<LDAP://" & strDomain & ">;(cn=" & strDistListName & ");*;subtree"
Set objRS = ADOconn.Execute(bstrADOQueryString)

If objRS.EOF Then
WScript.Echo "List not found."
End If

Set objObject = GetObject(objRS.Fields(0))

recurse_list objRS.Fields(0), 0

objRS.Close
ADOconn.Close
Set objRS = Nothing
Set ADOconn = Nothing
Set objObject = Nothing

Private Function recurse_list(strPath, intLevel)
Set objObject = GetObject(strPath)

objMembers = objObject.GetEx("member")

For Each member In objMembers

Set objMember = GetObject("LDAP://" & member)
If objMember.Class = "group" Then
WScript.Echo Space(intLevel * 3) & "GROUP: " & objMember.cn
recurse_list objMember.ADsPath, intLevel + 1
Else
If Instr(objMember.distinguishedName, "OU=Disabled Accounts") = 0 Then
WScript.Echo Space(intLevel * 3) & objMember.cn
End If
End If
Set objLocMember = Nothing
Next
End Function




Thanks-

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Extracting Email Addresses from a Email Distribution List

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap