Share via


IIsIPSecurity.IPDeny (ADSI)

The IPDeny method gets or sets an array of IP addresses that are not permitted to view the IIS site, service, virtual directory, or file. This is only effective if permission is permitted by default (if IIsIPSecurity.GrantByDefault (ADSI) is set to true).

[Visual Basic]
objIIsIPSecurity.IPDeny = <array of IP addresses>

Code Example

<% 
  ' Remember to enable Integrated Windows authentication and 
  ' disable Anonymous Access or you will get a Server 500 error. 
  Dim SecObj 
  Dim MyIPSec 
  Dim IPList 

  ' Get the IIS object that holds the info for the default site.  
  ' This could be any site root/vdir, or IIS://LocalHost/W3SVC for global  
  ' properties. 
  Set SecObj = GetObject("IIS://LocalHost/W3SVC/1/Root") 

  ' Get the IIsIPSecurity object. 
  Set MyIPSec = SecObj.IPSecurity 
  ' Make sure GrantByDefault=TRUE or your changes will not count.  
  If (FALSE = MyIPSec.GrantByDefault) Then 
Response.Write 
  "<BR>GrantByDefault was not TRUE. Setting to TRUE.<BR>" 
MyIPSec.GrantByDefault = TRUE 
  End If 
  ' Get the Deny list as an array, and add your new restricted IP address. 
  IPList = MyIPSec.IPDeny 
  Redim IPList (Ubound(IPList)+1) 
  IPList (Ubound(IPList)) = "123.0.0.1,255.255.255.0" 

  ' Set the new lists back in the metabase in two stages, and then set   
  ' the metabase. 
  MyIPSec.IPDeny = IPList 
  SecObj.IPSecurity = MyIPSec 
  SecObj.Setinfo 
  Response.Write "The IPRestriction has been set<BR>" 
%>

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

See Also

Concepts

IIsIPSecurity (ADSI)

Using ADSI to Configure IIS