WebDAV Lock Store Defintions <lockStores>

Overview

The WebDAV module is designed to support multiple lock store providers, which are defined in the webdav/globalSettings/lockStores collection. A series of <add> elements define the settings for each lock provider in the <lockStores> collection.

Note: Currently the only property store provider is webdav_simple_lock, which stores WebDAV locks in memory. Because this provider stores locks in memory, the locks are automatically released when IIS or an application pool are restarted.

Compatibility

Version Notes
IIS 7.5 The <lockStores> element ships as a feature of IIS 7.5.
IIS 7.0 The <lockStores> element was introduced in WebDAV 7.5 as part of a separate download for IIS 7.0.
IIS 6.0 N/A

Note: The <lockStores> element was defined in the WebDAV 7.0 schema, but was ignored because WebDAV locks were not implemented in that version.

Note: The WebDAV 7.0 and WebDAV 7.5 modules shipped out-of-band for IIS 7.0, which required downloading and installing the modules from the following URL:

http://www.iis.net/expand/WebDAV

With Windows 7 and Windows Server 2008 R2, the WebDAV 7.5 module ships as a feature for IIS 7.5, so downloading WebDAV is no longer necessary.

Setup

To support WebDAV publishing for your Web server, you must install the WebDAV module. To do so, use the following steps.

IIS 7.5 for Windows Server 2008 R2

  1. On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
  2. In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
  3. In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
  4. On the Select Role Services page of the Add Role Services Wizard, expand Common HTTP Features, select WebDAV Publishing, and then click Next.
  5. On the Confirm Installation Selections page, click Install.
  6. On the Results page, click Close.

IIS 7.5 for Windows 7

  1. On the taskbar, click Start, and then click Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
  3. Expand Internet Information Services, then World Wide Web Services, and then Common HTTP Features.
  4. Select WebDAV Publishing, and then click OK.

IIS 7.0 for Windows Server 2008 and Windows Vista

How To

How to configure WebDAV locking for a Web site

  1. Open Internet Information Services (IIS) Manager:
    • If you are using Windows Server 2008 or Windows Server 2008 R2:
      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:
      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. In the Connections pane, expand the server name, expand the Sites node, then click the name of the site.
  3. In the site's Home pane, double-click WebDAV Authoring Rules.
  4. When the WebDAV Authoring Rules page is displayed, click WebDAV Settings in the Actions pane.
  5. When the WebDAV Settings page is displayed, specify the following options in the Lock Behavior section:
    • Set Allow Locks to True.
    • For Lock Store, choose webdav_simple_lock from the drop-down list.
    • Set Require Lock for Writing to your desired setting.
  6. Once you have completed the steps, click Apply in the Actions pane.

Configuration

The <lockStores> element is only configurable at the global level in the ApplicationHost.config file. Any settings at the site or application level or in Web.config files are ignored.

Attributes

None.

Child Elements

Element Description
add

Optional element.

Specifies the settings for a lock store provider.

Configuration Sample

The following example lists a sample <globalSettings> element for a WebDAV server. This example defines the built-in simple providers for locks and properties, and enables WebDAV locks for the server.

   <system.webServer>
<webdav>
<globalSettings>
<propertyStores>
<add name="webdav_simple_prop" image="%windir%\system32\inetsrv\webdav_simple_prop.dll" />
</propertyStores>
<lockStores>
         <add name="webdav_simple_lock" image="%windir%\system32\inetsrv\webdav_simple_lock.dll" />
           </lockStores>
         </globalSettings>
         <authoring>
         <locks enabled="true" lockStore="webdav_simple_lock" />
         </authoring>
</webdav>
</system.webServer>

Sample Code

Note: The propertyStores and lockStores collections are populated with the built-in property and lock providers when you install WebDAV. These provider collections are not extensible at this time, so the code samples in this section are only for reference.

The following examples configure WebDAV global settings to re-add the built-in property and lock providers that are copied to your system when you install the WebDAV module.

AppCmd.exe

appcmd.exe set config -section:system.webServer/webdav/globalSettings /+"propertyStores.[name='webdav_simple_prop',image='%windir%\system32\inetsrv\webdav_simple_prop.dll']" /commit:apphost

appcmd.exe set config -section:system.webServer/webdav/globalSettings /+"lockStores.[name='webdav_simple_lock',image='%windir%\system32\inetsrv\webdav_simple_lock.dll']" /commit:apphost

Note: You must be sure to set the commit parameter to apphost when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection globalSettingsSection = config.GetSection("system.webServer/webdav/globalSettings");

         ConfigurationElementCollection propertyStoresCollection = globalSettingsSection.GetCollection("propertyStores");

         ConfigurationElement addElement = propertyStoresCollection.CreateElement("add");
         addElement["name"] = @"webdav_simple_prop";
         addElement["image"] = @"%windir%\system32\inetsrv\webdav_simple_prop.dll";
         propertyStoresCollection.Add(addElement);

         ConfigurationElementCollection lockStoresCollection = globalSettingsSection.GetCollection("lockStores");

         ConfigurationElement addElement1 = lockStoresCollection.CreateElement("add");
         addElement1["name"] = @"webdav_simple_lock";
         addElement1["image"] = @"%windir%\system32\inetsrv\webdav_simple_lock.dll";
         lockStoresCollection.Add(addElement1);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim globalSettingsSection As ConfigurationSection = config.GetSection("system.webServer/webdav/globalSettings")

      Dim propertyStoresCollection As ConfigurationElementCollection = globalSettingsSection.GetCollection("propertyStores")

      Dim addElement As ConfigurationElement = propertyStoresCollection.CreateElement("add")
      addElement("name") = "webdav_simple_prop"
      addElement("image") = "%windir%\system32\inetsrv\webdav_simple_prop.dll"
      propertyStoresCollection.Add(addElement)

      Dim lockStoresCollection As ConfigurationElementCollection = globalSettingsSection.GetCollection("lockStores")

      Dim addElement1 As ConfigurationElement = lockStoresCollection.CreateElement("add")
      addElement1("name") = "webdav_simple_lock"
      addElement1("image") = "%windir%\system32\inetsrv\webdav_simple_lock.dll"
      lockStoresCollection.Add(addElement1)

      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var globalSettingsSection = adminManager.GetAdminSection("system.webServer/webdav/globalSettings", "MACHINE/WEBROOT/APPHOST");

var propertyStoresCollection = globalSettingsSection.ChildElements.Item("propertyStores").Collection;

var addElement = propertyStoresCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "webdav_simple_prop";
addElement.Properties.Item("image").Value = "%windir%\\system32\\inetsrv\\webdav_simple_prop.dll";
propertyStoresCollection.AddElement(addElement);

var lockStoresCollection = globalSettingsSection.ChildElements.Item("lockStores").Collection;

var addElement1 = lockStoresCollection.CreateNewElement("add");
addElement1.Properties.Item("name").Value = "webdav_simple_lock";
addElement1.Properties.Item("image").Value = "%windir%\\system32\\inetsrv\\webdav_simple_lock.dll";
lockStoresCollection.AddElement(addElement1);

adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set globalSettingsSection = adminManager.GetAdminSection("system.webServer/webdav/globalSettings", "MACHINE/WEBROOT/APPHOST")

Set propertyStoresCollection = globalSettingsSection.ChildElements.Item("propertyStores").Collection

Set addElement = propertyStoresCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "webdav_simple_prop"
addElement.Properties.Item("image").Value = "%windir%\system32\inetsrv\webdav_simple_prop.dll"
propertyStoresCollection.AddElement(addElement)

Set lockStoresCollection = globalSettingsSection.ChildElements.Item("lockStores").Collection

Set addElement1 = lockStoresCollection.CreateNewElement("add")
addElement1.Properties.Item("name").Value = "webdav_simple_lock"
addElement1.Properties.Item("image").Value = "%windir%\system32\inetsrv\webdav_simple_lock.dll"
lockStoresCollection.AddElement(addElement1)

adminManager.CommitChanges()
Deprecated Elements