[This is preliminary documentation and subject to change]

### IPGrant

You can use the IPGrant property of the IIsIPSecurity object to edit lists of IP addresses, in an array, that are not allowed access to the server.

###### Syntax

SecObj.IPGrant = "IPAddress,SubnetMask"

varIPGrant = SecObj.IPGrant

###### Parameters

SecObj
  An IIS Admin Object of type IIsIPSecurity.
IPAddress
  This is a specific IP address you want to grant access to the server.

SubnetMask

This is the subnet mask for the specified IP address.

###### Code Example

`<%`

`' Remember to enable Integrated Windows Authentication and`

`' disable Anonymous Access or you will get and 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=FALSE or your changes will not count`

`If (TRUE = MyIPSec.GrantByDefault) Then`

`Response.Write`

`"<BR>GrantByDefault was not FALSE. Setting to FALSE.<BR>"`

`MyIPSec.GrantByDefault = FALSE`

`End If`

``

`' Get the Grant list, as an array, and add your new allowed IP`

`IPList = MyIPSec.IPGrant`

`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.IPGrant = IPList`

`SecObj.IPSecurity = MyIPSec`

`SecObj.Setinfo`

``

`Response.Write "The IPRestriction has been set<BR>"`

`%>`

###### See Also

IPDeny, DomainDeny, DomainGrant, GrantByDefault, IIsIPSecurity

© 1997-2001 Microsoft Corporation. All rights reserved.