473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Writing to IIS6 metabase and Type i = Type.GetTypeFromProgID("IPSecurity"); ???

I am trying to implement "Ban user IP" functionality in my webapp by
writing directly to IIS6 metabase. There is IPSecurity section that
allows deny access for specific ip addresses. Here Ive found some
samples but cant get it to work. Any help is greatly appreciated!

The problem occurs on this line: Type i =
Type.GetTypeFromProgID("IPSecurity");
"IPSecurity" progID is not correct. How do I get right one?

using System;
using System.DirectoryServices;
using System.Reflection;

DirectoryEntry defaultRoot = new DirectoryEntry("IIS://" + serverName
+ "/w3svc/1/root", serverName + "\\administrator", password,
AuthenticationTypes.Secure);

// Put the IPSecurity value into a collection.
PropertyValueCollection ipSecValCollection =
defaultRoot.Properties["IPSecurity"];

Type i = Type.GetTypeFromProgID("IPSecurity");

// System.Activator can create types of objects locally or remotely.
object newObj = Activator.CreateInstance(i);
i.InvokeMember("IPDeny",BindingFlags.Default |
BindingFlags.SetProperty, null,newObj, new object[] {"123.45.67.89"} )
;

// Put the new member into the collection and commit the
changes.
ipSecValCollection.Insert(0,newObj);
defaultRoot.CommitChanges();
defaultRoot.RefreshCache();
Nov 18 '05 #1
0 1126

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gernot Frisch | last post by:
er... what I want to know is: template <class T> void foo(void) { switch (typeof(T)) { } } Know what I mean?
5
by: Barry Kelly | last post by:
I'm running this version of Python: Python 2.4.3 (#1, May 18 2006, 07:40:45) on cygwin I read in the documentation that these two expressions are interchangeable: ...
2
by: Robert Towne | last post by:
What happens if I pass the assembly-qualified name of some type to "System.Type.GetType()" where the name I pass originates from another machine. For instance, for a standard button control, what...
2
by: Joseph Lu | last post by:
Hi, I have a multithread problem like the following lines, when I compile this code I caught a "error C2665", the error description is : none of the number1 overloads can convert parameter number2...
8
by: bonk | last post by:
When I have an instance of an object wich is of type System.Type, how can I find out if it directly or indirecly derives from another type? myTypeInstance == typeof(AnotherType) only seems to...
10
by: Yevgen Muntyan | last post by:
Consider the following macro: #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) The intent is to wrap raw memory allocation of N bytes into a macro which returns allocated chunk of memory...
9
by: Tony Johansson | last post by:
Hello! If I have string name = "Mytest"; and Type test1 = Type.GetType(name); and Type test2 = name.GetType(); then the first one will assign null to test1 but the second test2 will be given...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.