<?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; sendasrights</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/active-directory/sendasrights/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 send as rights on a user or resource account</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 15:58:40 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[sendasrights]]></category>
		<category><![CDATA[accescontrolentry]]></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[discretionaryacl]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[security descriptor]]></category>
		<category><![CDATA[send as]]></category>
		<category><![CDATA[sendas]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=234</guid>
		<description><![CDATA[This is the second script for today. It enumerates the &#8220;send as&#8221; rights on a user or resource account (mailbox). The &#8220;send as&#8221; rights are formatted as &#8220;domainprew2kname&#8221;. What the script does: ask for the smtp address of the user (inputbox) the function GetDN gets the distinguished name create the user/resource account object create the [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second script for today.<br />
It enumerates the &#8220;send as&#8221; rights on a user or resource account (mailbox).<br />
The &#8220;send as&#8221; rights are formatted as &#8220;domainprew2kname&#8221;. </p>
<p>What the script does:</p>
<ul>
<li>ask for the smtp address of the user (inputbox)</li>
<li>the function GetDN gets the distinguished name</li>
<li>create the user/resource account object</li>
<li>create the securitydescriptor, discretionaryacl en accesscontrolentry objects</li>
<li>enumerate all aces/accounts with the &#8220;send as&#8221; right</li>
<li>filter removed accounts (S-1&#8230;.) and &#8220;NT AUTHORITHYSELF&#8221;</li>
</ul>
<p>Follow the next steps to run the script  (no admin rights needed):</p>
<ul>
<li>find the smtp address of the user (outlook/aduc)</li>
<li>open your favorite text editor</li>
<li>copy and paste the script into the editor</li>
<li>save the script (for example c:tempsendas.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript sendas.vbs&#8221; (without quotes) and enter</li>
<li>in the input box fill in the smtp address of the user</li>
<li>give &#8220;ok&#8221;</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : sendas.vbs
' Description : script to enumerate the send as rights on a user or resource account
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 04-02-2010
' Level : advanced

strAccount = InputBox(&quot;Fill in the smtp address of the account&quot;)
strAccountDN = GetDN(strAccount)

Set objAccount = getobject(&quot;LDAP://&quot; &amp; strAccountDN)
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
			wscript.echo objAce.Trustee &amp; &quot; - send mail as&quot;
		End If
	End If
Next

Set objAce = Nothing
Set objDacl = Nothing
Set objSecurityDescriptor = Nothing
set objAccount = 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

	' 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)(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

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	GetDN = adoRecordset.Fields(&quot;distinguishedName&quot;).Value
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

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

End Function
</pre>
<p>If you have questions/problems or simply like the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV</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%2Fsendasrights%2Factive-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account%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/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/"></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/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/"  data-text="Active Directory: VBscript to enumerate the send as rights on a user or resource account" 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/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/sendasrights/active-directory-vbscript-to-enumerate-the-send-as-rights-on-a-user-or-resource-account/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

