Ask a Question related to ASP.NET Security, Design and Development.
-
DAve #1
Setting IPGrant on a folder from a WebMethod
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.CommitChan ges()
problem is going to be a security threat. Any thoughts or alternative>From the research I've done, I'm concerned that the solution to this
ideas to accomplish this?
Thanks,
David
DAve Guest
-
Unable to locate the folder Adobe PDF setting file or other resources
Get this message when trying to create a pdf file from an office document either from office or from Adobe 6.0 Professional. Using XP Professional OS... -
Setting writing permissions to a folder.
At ASP.Net application I have a folder which contains the files, being updated by the users. The application deployed by Web Setup project. The... -
Folder setting?
Hi, i want to set some limitation for each user's document on disk usage. for example, for user1's my documents, i want it not exceeds 100MB. is... -
Help with setting folder permissions
I'm running XP Home Edition on a Dell Dimension 8100, Pentium 4, 80 gig HD, 256 RAM (although none of that info will probably be needed to answer... -
Setting Folder Permissions
Hi, I am sooo lost with a problem I have. I bought a new digital camera and when I tried to install the software it got an error message "unable to... -
Joe Kaplan \(MVP - ADSI\) #2
Re: Setting IPGrant on a folder from a WebMethod
The IIS provider for ADSI doesn't use alternate credentials. It only works
based on the security context of the current thread. The credentials you
pass in are simply ignored.
In order to get this to work, you need to make the current security context
have the correct rights to perform the action.
Joe K.
"DAve" <dsalonius@pobox.com> wrote in message
news:1109004163.416526.183190@l41g2000cwc.googlegr oups.com...>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.CommitChan ges()
>> problem is going to be a security threat. Any thoughts or alternative>>From the research I've done, I'm concerned that the solution to this
> ideas to accomplish this?
>
> Thanks,
>
> David
>
Joe Kaplan \(MVP - ADSI\) Guest
-
David Salonius #3
Re: Setting IPGrant on a folder from a WebMethod
To change the current security context - would I accomplish this in my
web.config or machine.config files? Or would I need to use the
impersonate method?
Thanks for your help,
David
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
David Salonius Guest
-
David Salonius #4
Re: Setting IPGrant on a folder from a WebMethod
My web service is running under NT AUTHORITY\NETWORK SERVICE. I've then
given full control under folder security to that user. Under Advanced
Security Settings, I've verified that NETWORK SERVICE has full control
to all permissions. The error still persists. Is this what you're
referring to?
Thanks,
David
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
David Salonius Guest
-
Joe Kaplan \(MVP - ADSI\) #5
Re: Setting IPGrant on a folder from a WebMethod
My guess is that you need to be an administrator in order to change the IIS
metabase. That is normally required.
Did you consider changing the Application Pool identity to an administrator
account? That should accomplish your goal, at least for testing purposes.
However, you may not wish to solve the problem that way. Running your app
pool as administrator opens you up to some significant security risks. You
may wish to put the IIS ADSI code in a COM+ component and run that under a
separate identity with admin privileges. This would allow your main web
application process to continue running with least privileges (as NETWORK
SERVICE).
Joe K.
"David Salonius" <dsalonius@charter.net> wrote in message
news:OnizSDEGFHA.560@TK2MSFTNGP15.phx.gbl...>
> My web service is running under NT AUTHORITY\NETWORK SERVICE. I've then
> given full control under folder security to that user. Under Advanced
> Security Settings, I've verified that NETWORK SERVICE has full control
> to all permissions. The error still persists. Is this what you're
> referring to?
>
> Thanks,
>
> David
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Joe Kaplan \(MVP - ADSI\) Guest
-
IPGrunt #6
Re: Setting IPGrant on a folder from a WebMethod
On 21 Feb 2005, David Salonius <dsalonius@charter.net> postulated in
news:OnizSDEGFHA.560@TK2MSFTNGP15.phx.gbl:
then>
> My web service is running under NT AUTHORITY\NETWORK SERVICE. I'veAdvanced> given full control under folder security to that user. Undercontrol> Security Settings, I've verified that NETWORK SERVICE has fullUse IIS to manage this for you, buy assigning a new application pool> to all permissions. The error still persists. Is this what you're
> referring to?
>
> Thanks,
>
> David
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
for this site that impersonates administrator (using LocalSystem as
Identity). (I use one called AdmininstrationPool that I keep reserved
for roles where I need this level access).
Remember, This IS a security hole, so be careful who has access.
-- ipgrunt
IPGrunt Guest
-
David Salonius #7
Re: Setting IPGrant on a folder from a WebMethod
Setting the user in the Application Pool identity to an administrator
account solved the problem. From what I can tell, as long as my web
methods folder is locked down to where no one can upload code, this
should be safe. Is that a fair assessment?
Thanks,
David
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
David Salonius Guest
-
Joe Kaplan \(MVP - ADSI\) #8
Re: Setting IPGrant on a folder from a WebMethod
I'd make sure you don't use that app pool for any other websites or
applications on the same server. Always use a different app pool with lower
privileges for other sites. That will help restrict it as well.
Other than that, it is up to you to consider whether you need to go to COM+
or not for additional security. As long as you don't have any other entry
points into this site and you are comfortable with the security you are
providing, then I think it can be secure. Just be careful and spend some
time doing some threat modeling to make sure you don't miss anything.
Joe K.
"David Salonius" <dsalonius@charter.net> wrote in message
news:%23MKOlGFGFHA.228@TK2MSFTNGP15.phx.gbl...>
>
> Setting the user in the Application Pool identity to an administrator
> account solved the problem. From what I can tell, as long as my web
> methods folder is locked down to where no one can upload code, this
> should be safe. Is that a fair assessment?
>
> Thanks,
>
> David
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Joe Kaplan \(MVP - ADSI\) Guest



Reply With Quote

