IISIPSecurity

  • Thread starter Thread starter andrew lowe
  • Start date Start date
A

andrew lowe

Hi,

This was originally posted in framework.interop but am trying here now.

I'm trying to define the IISIPSecurity interface described at
http://msdn.microsoft.com/library/d...ry/en-us/iissdk/iis/ref_prog_iaorefiipsec.asp.
I'm getting a NullReferenceException when i try to set the GrantByDefault
property, eg:

IISIPSecurity ipSecurity =
(IISIPSecurity)entry.Properties["IPSecurity"].Value;
bool grantByDefault;
ipSecurity.GrantByDefault(out grantByDefault);
grantByDefault = false;

// Exception thrown here
ipSecurity.GrantByDefault(grantByDefault);


I've defined the interface as:

[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
GuidAttribute("F3287521-BBA3-11D0-9BDC-00A0C922E703")]
public interface IISIPSecurity
{
[PreserveSig, DispId(4)]
int IPDeny([Out, MarshalAs(UnmanagedType.SafeArray)] out object retVal);
[PreserveSig, DispId(4)]
int IPDeny([In, MarshalAs(UnmanagedType.SafeArray)] object rhs);
[PreserveSig, DispId(5)]
int IPGrant([Out, MarshalAs(UnmanagedType.SafeArray)] out object retVal);
[PreserveSig, DispId(5)]
int IPGrant([In, MarshalAs(UnmanagedType.SafeArray)] object rhs);
[PreserveSig, DispId(6)]
int DomainDeny([Out, MarshalAs(UnmanagedType.SafeArray)] out object retVal);
[PreserveSig, DispId(6)]
int DomainDeny([In, MarshalAs(UnmanagedType.SafeArray)] object rhs);
[PreserveSig, DispId(7)]
int DomainGrant([Out, MarshalAs(UnmanagedType.SafeArray)] out object
retVal);
[PreserveSig, DispId(7)]
int DomainGrant([In, MarshalAs(UnmanagedType.SafeArray)] object rhs);
[PreserveSig, DispId(8)]
int GrantByDefault([Out, MarshalAs(UnmanagedType.VariantBool)] out bool
retVal);
[PreserveSig, DispId(8)]
int GrantByDefault([In, MarshalAs(UnmanagedType.VariantBool)] bool rhs);
}

Do I have faults with the interface definition ?
tia
andrew
 
There is no need to define the interface, just add a reference to the IIS
namespace provider (adsiis.dll), this will make the IISOle namespace
available and you will be able to do things like......

PropertyValueCollection ipSecValCollection =
entry.Properties["IPSecurity"];

IISOle.IPSecurityClass ipSecClass = new IISOle.IPSecurityClass();
ipSecClass.GrantByDefault = true;
ipSecClass.IPDeny = "192.168.0.1,255.255.255.0";
ipSecValCollection.Add( ipSecClass);
entry.CommitChanges();

Willy.
 
Willy Denoyette said:
There is no need to define the interface, just add a reference to the IIS
namespace provider (adsiis.dll), this will make the IISOle namespace
available and you will be able to do things like......

PropertyValueCollection ipSecValCollection =
entry.Properties["IPSecurity"];

IISOle.IPSecurityClass ipSecClass = new IISOle.IPSecurityClass();
ipSecClass.GrantByDefault = true;
ipSecClass.IPDeny = "192.168.0.1,255.255.255.0";
ipSecValCollection.Add( ipSecClass);
entry.CommitChanges();


Wicked, thanks willy
 
Back
Top