<?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>siliconpizza.com &#187; IIS Admin</title>
	<atom:link href="http://siliconpizza.com/blog/tag/iis-admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://siliconpizza.com</link>
	<description>I'll have a slice of that</description>
	<lastBuildDate>Mon, 11 Jul 2011 14:57:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<style type="text/css">
@import url(http://www.google.com/cse/api/branding.css);
</style>
<div class="cse-branding-right" style="background-color:#FFFFFF;color:#000000">
  <div class="cse-branding-form">
    <form action="http://www.google.co.uk/cse" id="cse-search-box" target="_blank">
      <div>
        <input type="hidden" name="cx" value="partner-pub-0990092444456571:mfibeucn22n" />
        <input type="hidden" name="ie" value="ISO-8859-1" />
        <input type="text" name="q" size="31" />
        <input type="submit" name="sa" value="Search" />
      </div>
    </form>
  </div>
  <div class="cse-branding-logo">
    <img src="http://www.google.com/images/poweredby_transparent/poweredby_FFFFFF.gif" alt="Google" />
  </div>
  <div class="cse-branding-text">
    Custom Search
  </div>
</div>

<script type="text/javascript"><!--
google_ad_client = "pub-0990092444456571";
/* 728x90, created 7/24/08 */
google_ad_slot = "4348084769";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>	<item>
		<title>IIS IP Secuirty</title>
		<link>http://siliconpizza.com/blog/2008/04/24/iis-ip-secuirty/</link>
		<comments>http://siliconpizza.com/blog/2008/04/24/iis-ip-secuirty/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 13:48:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[IIS Admin]]></category>
		<category><![CDATA[IISIPSecurity]]></category>

		<guid isPermaLink="false">http://siliconpizza.com/blog/2008/04/24/iis-ip-secuirty/</guid>
		<description><![CDATA[Carrying on from my IIS admin via a web service work, i needed to apply IPSecurity restrictions to some of the sites that would be created. Plently of googling revealed some information about an IISIPSecurity class in .NET 3.0 and above, but i could only rough c# sample code here , and that was for [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=8cc0ef4416d627c65d4771f7e5701b17&amp;default=' alt='No Gravatar' width=40 height=40/><p>Carrying on from my IIS admin via a web service work, i needed to apply IPSecurity restrictions to some of the sites that would be created.</p>
<p>Plently of googling revealed some information about an IISIPSecurity class in .NET 3.0 and above, but i could only rough c# sample code<a href="http://msdn2.microsoft.com/en-us/library/ms524322(VS.85).aspx" title="MS Sample Code"> here</a> , and that was for a console app</p>
<p>so after many failed attempts to convert to VB.NET to work with my web service, and even tried the ADSIIIS.dll com interop, i gave up and converted the c# code into an assembly , which works. I know hind sight is 20:20, but i shodul have just done that in the first place</p>
<p>my code is here</p>
<p><span id="more-248"></span></p>
<p><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System.Collections.Generic;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System.Linq;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System.Text;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System.DirectoryServices;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">using</font></font><font size="2"> System.Reflection;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">namespace</font></font><font size="2"> IISSecurity<br />
{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">public</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">class</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">IISIPSecurity<br />
</font></font><font size="2">{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">static</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2"> SetIPSecurityProperty(</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2"> metabasePath, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2"> member, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2"> item)<br />
{</font><font size="2"><font size="2" color="#008000"><font size="2" color="#008000">// metabasePath is of the form &#8220;IIS://&lt;servername&gt;/&lt;path&gt;&#8221;<br />
</font></font><font size="2" color="#008000"><font size="2" color="#008000">// for example &#8220;IIS://localhost/SMTPSVC/1&#8243;<br />
</font></font><font size="2" color="#008000"><font size="2" color="#008000">// member is of the form &#8220;IPGrant|IPDeny|DomainGrant|DomainDeny&#8221;<br />
</font></font><font size="2" color="#008000"><font size="2" color="#008000">// item is of the form &#8220;&lt;ipaddress|domain&gt;&#8221;, for example, 157.56.236.15 or domain.microsoft.com</font></font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">try<br />
</font></font><font size="2">{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">if</font></font><font size="2"> ((</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;IPGrant&#8221;</font></font><font size="2"> != member) &amp;&amp; (</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;IPDeny&#8221;</font></font><font size="2"> != member) &amp;&amp; (</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;DomainGrant&#8221;</font></font><font size="2"> != member) &amp;&amp; (</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;DomainDeny&#8221;</font></font><font size="2"> != member))<br />
{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> return</font></font><font size="2"> </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;Failed in SetIPSecurityProperty; second param must be one of IPGrant|IPDeny|DomainGrant|DomainDeny&#8221;</font></font><font size="2">;<br />
}</font><font size="2"><font size="2" color="#0000ff"><font size="2" color="#0000ff">else</font></font></font><font size="2"><font size="2">{<br />
<font size="2" color="#2b91af"><font size="2" color="#2b91af"> DirectoryEntry</font></font><font size="2"> path = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">DirectoryEntry</font></font><font size="2">(metabasePath);<br />
 path.RefreshCache();<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> object</font></font><font size="2"> ipsecObj = path.Invoke(</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;Get&#8221;</font></font><font size="2">, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2">[] { </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;IPSecurity&#8221;</font></font><font size="2"> });<br />
</font><font size="2" color="#2b91af"><font size="2" color="#2b91af"> Type</font></font><font size="2"> t = ipsecObj.GetType();<br />
</font><font size="2" color="#2b91af"><font size="2" color="#2b91af"> Array</font></font><font size="2"> data = (</font><font size="2" color="#2b91af"><font size="2" color="#2b91af">Array</font></font><font size="2">)t.InvokeMember(member, </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">BindingFlags</font></font><font size="2">.GetProperty, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">null</font></font><font size="2">, ipsecObj, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">null</font></font><font size="2">);<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> bool</font></font><font size="2"> exists = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">false</font></font><font size="2">;<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> foreach</font></font><font size="2"> (</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">object</font></font><font size="2"> dataItem </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">in</font></font><font size="2"> data)<br />
 {<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">if</font></font><font size="2"> (dataItem.ToString().StartsWith(item))<br />
 {<br />
 exists = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">true</font></font><font size="2">;<br />
 }<br />
}<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">if</font></font><font size="2"> (exists)<br />
{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> return</font></font><font size="2"> </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;Not appling already exists&#8221;</font></font><font size="2">;<br />
}<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> else<br />
</font></font><font size="2">{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> object</font></font><font size="2">[] newData = </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">object</font></font><font size="2">[data.Length + 1];<br />
 data.CopyTo(newData, 0);<br />
 newData.SetValue(item, data.Length);<br />
 t.InvokeMember(member, </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">BindingFlags</font></font><font size="2">.SetProperty, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">null</font></font><font size="2">, ipsecObj, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">object</font></font><font size="2">[] { newData });<br />
 path.Invoke(</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;Put&#8221;</font></font><font size="2">, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">object</font></font><font size="2">[] { </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;IPSecurity&#8221;</font></font><font size="2">, ipsecObj });<br />
 path.CommitChanges();<br />
 path.RefreshCache();<br />
 ipsecObj = path.Invoke(</font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;Get&#8221;</font></font><font size="2">, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">new</font></font><font size="2"> </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">string</font></font><font size="2">[] { </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;IPSecurity&#8221;</font></font><font size="2"> });<br />
 data = (</font><font size="2" color="#2b91af"><font size="2" color="#2b91af">Array</font></font><font size="2">)t.InvokeMember(member, </font><font size="2" color="#2b91af"><font size="2" color="#2b91af">BindingFlags</font></font><font size="2">.GetProperty, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">null</font></font><font size="2">, ipsecObj, </font><font size="2" color="#0000ff"><font size="2" color="#0000ff">null</font></font><font size="2">);<br />
 }<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> return</font></font><font size="2"> </font><font size="2" color="#a31515"><font size="2" color="#a31515">&#8220;OK&#8221;</font></font><font size="2">;<br />
}<br />
}<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff">catch</font></font><font size="2"> (</font><font size="2" color="#2b91af"><font size="2" color="#2b91af">Exception</font></font><font size="2"> ex)<br />
</font><font size="2">{<br />
</font><font size="2" color="#0000ff"><font size="2" color="#0000ff"> return</font></font><font size="2"> ex.Message;<br />
}<br />
}<br />
}<br />
}</font></font></p>
<p></font></p>
]]></content:encoded>
			<wfw:commentRss>http://siliconpizza.com/blog/2008/04/24/iis-ip-secuirty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IIS Admin using .NET and System.DirectoryServices Remotely gives Unknown error (0&#215;80005000)</title>
		<link>http://siliconpizza.com/blog/2008/04/23/iis-admin-using-net-and-systemdirectoryservices-remotely/</link>
		<comments>http://siliconpizza.com/blog/2008/04/23/iis-admin-using-net-and-systemdirectoryservices-remotely/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 11:05:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[IIS Admin]]></category>
		<category><![CDATA[Unknown error (0x80005000)]]></category>

		<guid isPermaLink="false">http://siliconpizza.com/blog/2008/04/23/iis-admin-using-net-and-systemdirectoryservices-remotely/</guid>
		<description><![CDATA[For the Past week or so I have been developing a series of webservices to Manage IIS setting on a Large web cluster as single entity, and for days i have been bettling with a Unknown error (0&#215;80005000). Plenty of Googling and MSDN Searching all talked about permisions issues. But most of the code worked on the target [...]]]></description>
			<content:encoded><![CDATA[<img style='float: left; margin-right: 10px; border: none;' src='http://www.gravatar.com/avatar.php?gravatar_id=8cc0ef4416d627c65d4771f7e5701b17&amp;default=' alt='No Gravatar' width=40 height=40/><p>For the Past week or so I have been developing a series of webservices to Manage IIS setting on a Large web cluster as single entity, and for days i have been bettling with a Unknown error (0&#215;80005000). Plenty of Googling and MSDN Searching all talked about permisions issues. But most of the code worked on the target web server, just not on my laptop under Visual Studio</p>
<p>So i chucked a<br />
<font size="2">System.Security.Principal.</font><font size="2" color="#2b91af"><font size="2" color="#2b91af">WindowsIdentity</font></font><font size="2">.GetCurrent().Name<br />
</font>Into my code and confirmed the USER ID is all correct.</p>
<p>So after a few head aches and some desk thumping, I closed visual Studio and reverted to first principles.</p>
<p>I started up compmgmt.msc and tried to connect to my target web server,  when i notice the web server snap in was not present. having now installed the IIS admin tools on my XP laptop,</p>
<p>Now it all works perfectly</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconpizza.com/blog/2008/04/23/iis-admin-using-net-and-systemdirectoryservices-remotely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

