<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vbscriptblog.com &#187; messagerestrictions</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/active-directory/messagerestrictions/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbscriptblog.com</link>
	<description>Scripting for Windows Sysadmins</description>
	<lastBuildDate>Wed, 11 Apr 2012 07:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v3</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 15:26:35 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[messagerestrictions]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=868</guid>
		<description><![CDATA[Pol asked me if it is possible to enter the Distinguished Name in the textbox. So I did a small rewrite of the script (Essentially it got shorter because the GetDN function was superfluous). Follow the next steps to run the script (no admin rights needed): * find the distinguished name of the nested group [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://deludi.nl/blog/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/comment-page-1/#comment-202">Pol</a> asked me if it is possible to enter the Distinguished Name in the textbox.<br />
So I did a small rewrite of the script (Essentially it got shorter because the GetDN function was superfluous).</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* find the distinguished name of the nested group (adsiedit.msc)<br />
* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the distinguished name<br />
* save the script (for example c:\temp\enumeratesendtorights.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript enumeratesendtorights.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratesendtorights.vbs
' Description : script to enumerate the message restrictions (send to rights) of a distributionlist
' Author : dirk adamsky - deludi bv
' Version : 3.00 added Distinguished Name input option based on input from Pol (see comments on previous script), removed the smtp input option
' Date : 16-11-2010
' Level: advanced

strObject = InputBox(&quot;Please enter the Distinguished Name&quot;)
Set objSource = GetObject(&quot;LDAP://&quot; &amp; strObject)
If TypeName(objSource.authOrig) = &quot;String&quot; Then
	GetSendToRights (&quot;LDAP://&quot; &amp; objSource.authOrig)
Else
	For Each User In objSource.authOrig
		GetSendToRights (&quot;LDAP://&quot; &amp; User)
	Next
End If
If TypeName(objSource.dLMemSubmitPerms) = &quot;String&quot; Then
	EnumNestedgroup objSource.dLMemSubmitPerms
Else
	For Each Group in objSource.dLMemSubmitPerms
		EnumNestedgroup Group
	Next
End If
Set objSource = Nothing

Function GetSendToRights(strUserDN)
	On Error Resume Next
	Set objAccount = GetObject(strUserDN)
	Wscript.Echo objAccount.Mail &amp; &quot; ; &quot; &amp; objAccount.DisplayName &amp; &quot; ; direct send to rights&quot;
	Set objSecurityDescriptor = objAccount.Get(&quot;ntSecurityDescriptor&quot;)
	Set objDacl = objSecurityDescriptor.DiscretionaryAcl
	Set objAce = CreateObject(&quot;AccessControlEntry&quot;)
	For Each objAce In objDacl
		If objAce.ObjectType = &quot;{AB721A54-1E2F-11D0-9819-00AA0040529B}&quot; Then
			If (Left(objAce.Trustee,3) &lt;&gt; &quot;S-1&quot; And objAce.Trustee &lt;&gt; &quot;NT AUTHORITYSELF&quot;) Then
				GetUserDetails Mid(objAce.Trustee,9)
			End If
		End If
	Next
End Function

Function GetUserDetails(strPreW2K)
	Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
	Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
	adoConnection.Provider = &quot;ADsDSOObject&quot;
	adoConnection.Open &quot;Active Directory Provider&quot;
	adoCommand.ActiveConnection = adoConnection

	' Search entire Active Directory domain.
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName=&quot; &amp;  strPreW2K &amp; &quot;))&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;mail, displayname&quot;

	' Construct the LDAP syntax query.
	strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
	adoCommand.CommandText = strQuery
	adoCommand.Properties(&quot;Page Size&quot;) = 100
	adoCommand.Properties(&quot;Timeout&quot;) = 30
	adoCommand.Properties(&quot;Cache Results&quot;) = False

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	Wscript.Echo adoRecordset.Fields(&quot;mail&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; indirect send to rights&quot;
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(&quot;LDAP://&quot; &amp; strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			GetSendToRights objMember.AdsPath
		End If
	Next
	Set objGroup = Nothing
End Sub
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Fmessagerestrictions%2Factive-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"  data-text="Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v3" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v2</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 12:08:01 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[messagerestrictions]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[distribution group]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[memberships]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=684</guid>
		<description><![CDATA[Suffering from a lack of inspiration I decided to rework a previous script. I had a request on my previous messagerestriction script. Added to the script is the option to enter the smtp address of the user or group object for which the messagerestrictions are set. I have done that by re-using code from this [...]]]></description>
			<content:encoded><![CDATA[<p>Suffering from a lack of inspiration I decided to rework a previous script.<br />
I had a request on my previous <a href="http://deludi.nl/blog/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/comment-page-1/#comment-104">messagerestriction script</a>.<br />
Added to the script is the option to enter the smtp address of<br />
the user or group object for which the messagerestrictions are set.<br />
I have done that by re-using code from <a href="http://deludi.nl/blog/vbscript/active-directory/active-directory-vbscript-to-change-the-groups-from-a-user-based-on-an-example-user/">this script</a>.<br />
Another question was the option to output to a file,<br />
this can be done easily by running the script like this:</p>
<p>cscript enumeratesendtorights.vbs > thefilenameofyourchoice.txt.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* find the distinguished name of the nested group (adsiedit.msc)<br />
* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the distinguished name<br />
* save the script (for example c:tempenumeratesendtorights.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:temp&#8221;<br />
* give &#8220;cscript enumeratesendtorights.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratesendtorights.vbs
' Description : script to enumerate the message restrictions (send to rights) of a distributionlist
' Author : dirk adamsky - deludi bv
' Version : 2.00 added smtp input option based on input from M (see comments on previous script)
' Date : 20-08-2010 (v.1.00 date 08-02-2010)
' Level: advanced

strObject = InputBox(&quot;Please enter the smtp address&quot;)
Set objSource = GetObject(&quot;LDAP://&quot; &amp; GetDN(strObject))
If TypeName(objSource.authOrig) = &quot;String&quot; Then
	GetSendToRights (&quot;LDAP://&quot; &amp; objSource.authOrig)
Else
	For Each User In objSource.authOrig
		GetSendToRights (&quot;LDAP://&quot; &amp; User)
	Next
End If
If TypeName(objSource.dLMemSubmitPerms) = &quot;String&quot; Then
	EnumNestedgroup objSource.dLMemSubmitPerms
Else
	For Each Group in objSource.dLMemSubmitPerms
		EnumNestedgroup Group
	Next
End If
Set objSource = Nothing

Function GetDN(strMail)
	Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
	Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
	adoConnection.Provider = &quot;ADsDSOObject&quot;
	adoConnection.Open &quot;Active Directory Provider&quot;
	adoCommand.ActiveConnection = adoConnection
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; objRootDSE.Get(&quot;defaultNamingContext&quot;) &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(mail=&quot; &amp;  strMail &amp; &quot;)&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;distinguishedName&quot;

	' Construct the LDAP syntax query.
	strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
	adoCommand.CommandText = strQuery
	adoCommand.Properties(&quot;Page Size&quot;) = 100
	adoCommand.Properties(&quot;Timeout&quot;) = 30
	adoCommand.Properties(&quot;Cache Results&quot;) = False
	Set adoRecordset = adoCommand.Execute
	wscript.echo adoRecordset.Fields(&quot;distinguishedName&quot;).Value
	GetDN = adoRecordset.Fields(&quot;distinguishedName&quot;).Value
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing

End Function

Function GetSendToRights(strUserDN)
	On Error Resume Next
	Set objAccount = GetObject(strUserDN)
	Wscript.Echo objAccount.Mail &amp; &quot; ; &quot; &amp; objAccount.DisplayName &amp; &quot; ; direct send to rights&quot;
	Set objSecurityDescriptor = objAccount.Get(&quot;ntSecurityDescriptor&quot;)
	Set objDacl = objSecurityDescriptor.DiscretionaryAcl
	Set objAce = CreateObject(&quot;AccessControlEntry&quot;)
	For Each objAce In objDacl
		If objAce.ObjectType = &quot;{AB721A54-1E2F-11D0-9819-00AA0040529B}&quot; Then
			If (Left(objAce.Trustee,3) &lt;&gt; &quot;S-1&quot; And objAce.Trustee &lt;&gt; &quot;NT AUTHORITYSELF&quot;) Then
				GetUserDetails Mid(objAce.Trustee,9)
			End If
		End If
	Next
End Function

Function GetUserDetails(strPreW2K)
	Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
	Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
	adoConnection.Provider = &quot;ADsDSOObject&quot;
	adoConnection.Open &quot;Active Directory Provider&quot;
	adoCommand.ActiveConnection = adoConnection

	' Search entire Active Directory domain.
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName=&quot; &amp;  strPreW2K &amp; &quot;))&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;mail, displayname&quot;

	' Construct the LDAP syntax query.
	strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
	adoCommand.CommandText = strQuery
	adoCommand.Properties(&quot;Page Size&quot;) = 100
	adoCommand.Properties(&quot;Timeout&quot;) = 30
	adoCommand.Properties(&quot;Cache Results&quot;) = False

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	Wscript.Echo adoRecordset.Fields(&quot;mail&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; indirect send to rights&quot;
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function	

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(&quot;LDAP://&quot; &amp; strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			GetSendToRights objMember.AdsPath
		End If
	Next
	Set objGroup = Nothing
End Sub
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Fmessagerestrictions%2Factive-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"  data-text="Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v2" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the message restrictions (send to rights) of a distributionlist</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 11:58:23 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[messagerestrictions]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[distribution group]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[members]]></category>
		<category><![CDATA[message restrictions]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[resource mailbox]]></category>
		<category><![CDATA[rights]]></category>
		<category><![CDATA[send to]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=255</guid>
		<description><![CDATA[Finally I can show you my script to enumerate the message restrictions (send to rights as I tend to call then) on a distributionlist. The send to rights consists of 2 pieces, the users and the groups rights. The users with send to rights are enumerated in the authOrig attribute of the distribution list AD [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I can show you my script to enumerate the message restrictions (send to rights as I tend to call then) on a distributionlist. The send to rights consists of 2 pieces, the users and the groups rights.<br />
The users with send to rights are enumerated in the authOrig attribute of the distribution list AD object, the groups are allocated in the dLMemSubmitPerms attribute. Both attributes are arrays.<br />
I also found out that when a listed user or resource mailbox had send as rights on it&#8217;s Active Directory object the users listed in the send as also have send to rights on the distribution list.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* find the distinguished name of the nested group (adsiedit.msc)<br />
* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the distinguished name<br />
* save the script (for example c:tempenumeratesendtorights.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:temp&#8221;<br />
* give &#8220;cscript enumeratesendtorights.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratesendtorights.vbs
' Description : script to enumerate the message restrictions (send to rights) of a distributionlist
' Author : dirk adamsky - deludi bv
' Version : 1.10 added check on attribute type based on input from Pedro (see comments)
' Date : 11-03-2010 (v.1.00 date 08-02-2010)
' Level: advanced

Set objSourceGroup = GetObject(&quot;LDAP://CN=distribution list (all members),OU=groups,DC=test,DC=org&quot;)
If objSourceGroup.authOrig &lt;&gt; &quot;&quot; Then
	If TypeName(objSourceGroup.authOrig) = &quot;String&quot; Then
		GetSendToRights (&quot;LDAP://&quot; &amp; objSourceGroup.authOrig)
	Else
		For Each User In objSourceGroup.authOrig
			GetSendToRights (&quot;LDAP://&quot; &amp; User)
		Next
	End If
End If
If objSourceGroup.dLMemSubmitPerms &lt;&gt; &quot;&quot; Then
	If TypeName(objSourceGroup.dLMemSubmitPerms) = &quot;String&quot; Then
		EnumNestedgroup objSourceGroup.dLMemSubmitPerms
	Else
		For Each Group in objSourceGroup.dLMemSubmitPerms
			EnumNestedgroup Group
		Next
	End If
End If
Set objSourceGroup = Nothing

Function GetSendToRights(strUserDN)
	On Error Resume Next
	Set objAccount = GetObject(strUserDN)
	Wscript.Echo objAccount.Mail &amp; &quot; ; &quot; &amp; objAccount.DisplayName &amp; &quot; ; direct send to rights&quot;
	Set objSecurityDescriptor = objAccount.Get(&quot;ntSecurityDescriptor&quot;)
	Set objDacl = objSecurityDescriptor.DiscretionaryAcl
	Set objAce = CreateObject(&quot;AccessControlEntry&quot;)
	For Each objAce In objDacl
		If objAce.ObjectType = &quot;{AB721A54-1E2F-11D0-9819-00AA0040529B}&quot; Then
			If (Left(objAce.Trustee,3) &lt;&gt; &quot;S-1&quot; And objAce.Trustee &lt;&gt; &quot;NT AUTHORITYSELF&quot;) Then
				GetUserDetails Mid(objAce.Trustee,9)
			End If
		End If
	Next
End Function

Function GetUserDetails(strPreW2K)
	Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
	Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
	adoConnection.Provider = &quot;ADsDSOObject&quot;
	adoConnection.Open &quot;Active Directory Provider&quot;
	adoCommand.ActiveConnection = adoConnection

	' Search entire Active Directory domain.
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName=&quot; &amp;  strPreW2K &amp; &quot;))&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;mail, displayname&quot;

	' Construct the LDAP syntax query.
	strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
	adoCommand.CommandText = strQuery
	adoCommand.Properties(&quot;Page Size&quot;) = 100
	adoCommand.Properties(&quot;Timeout&quot;) = 30
	adoCommand.Properties(&quot;Cache Results&quot;) = False

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	Wscript.Echo adoRecordset.Fields(&quot;mail&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; indirect send to rights&quot;
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function	

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(&quot;LDAP://&quot; &amp; strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			GetSendToRights objMember.AdsPath
		End If
	Next
	Set objGroup = Nothing
End Sub
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Fmessagerestrictions%2Factive-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/"  data-text="Active Directory: VBscript to enumerate the message restrictions (send to rights) of a distributionlist" data-count="horizontal" data-via="dirkadamsky"></a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

