Setting IPGrant on a folder from a WebMethod
From: DAve (dsalonius_at_pobox.com)
Date: 02/21/05
- Previous message: Petar Popara: "IIS user (IUSR_XXX) - CryptoAPI"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: Setting IPGrant on a folder from a WebMethod"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: Setting IPGrant on a folder from a WebMethod"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 21 Feb 2005 08:42:43 -0800
I want to be able to limit access to a folder in IIS by IP address. I
am trying to add IP addresses from a WebMethod to the IPGrant property.
Here's my code:
DirectoryEntry defaultRoot = new
DirectoryEntry("IIS://SERVERNAME/w3svc/1/root/examplefolder",username,password,
AuthenticationTypes.Secure);
defaultRoot.RefreshCache();
object oIPSecurity = defaultRoot.Invoke("Get", new
string[]{"IPSecurity"});
Type t = oIPSecurity.GetType();
//Get the list of granted IPs
Array IPs = (Array)t.InvokeMember("IPGrant", BindingFlags.GetProperty,
null, oIPSecurity, null);
//create a new Array of IPs
object[] newIPs = new object[IPs.Length+1];
//copy the existing IPs to the new Array
IPs.CopyTo(newIPs,0);
//add a new value
newIPs.SetValue("192.168.0.21",IPs.Length);
//Set the new IPlist
t.InvokeMember("IPGrant", BindingFlags.SetProperty, null, oIPSecurity,
new object[]{newIPs});
defaultRoot.Invoke("Put", new object[]{"IPSecurity", oIPSecurity});
defaultRoot.CommitChanges();
When executed, I get this error:
System.UnauthorizedAccessException: Access is denied. at
System.DirectoryServices.Interop.IAds.SetInfo() at
System.DirectoryServices.DirectoryEntry.CommitChanges()
>>From the research I've done, I'm concerned that the solution to this
problem is going to be a security threat. Any thoughts or alternative
ideas to accomplish this?
Thanks,
David
- Previous message: Petar Popara: "IIS user (IUSR_XXX) - CryptoAPI"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: Setting IPGrant on a folder from a WebMethod"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: Setting IPGrant on a folder from a WebMethod"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|