Adding WebDAV Lock Stores <add>
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 10.0 | The <add> element was not modified in IIS 10.0. |
IIS 8.5 | The <add> element was not modified in IIS 8.5. |
IIS 8.0 | The <add> element was not modified in IIS 8.0. |
IIS 7.5 | The <add> element of the <lockStores> element ships as a feature of IIS 7.5. |
IIS 7.0 | The <add> element of 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 <add>
element of 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:
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.
Windows Server 2012 or Windows Server 2012 R2
- On the taskbar, click Server Manager.
- In Server Manager, click the Manage menu, and then click Add Roles and Features.
- In the Add Roles and Features wizard, click Next. Select the installation type and click Next. Select the destination server and click Next.
- On the Server Roles page, expand Web Server (IIS), expand Web Server, expand Common HTTP Features, and then select WebDAV Publishing. Click Next.
- On the Select features page, click Next.
- On the Confirm installation selections page, click Install.
- On the Results page, click Close.
Windows 8 or Windows 8.1
- On the Start screen, move the pointer all the way to the lower left corner, right-click the Start button, and then click Control Panel.
- In Control Panel, click Programs and Features, and then click Turn Windows features on or off.
- Expand Internet Information Services, expand World Wide Web Services, expand Common HTTP Features, and then select WebDAV Publishing.
- Click OK.
- Click Close.
Windows Server 2008 R2
- On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
- In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
- In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
- On the Select Role Services page of the Add Role Services Wizard, expand Common HTTP Features, select WebDAV Publishing, and then click Next.
- On the Confirm Installation Selections page, click Install.
- On the Results page, click Close.
Windows 7
- On the taskbar, click Start, and then click Control Panel.
- In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
- Expand Internet Information Services, then World Wide Web Services, and then Common HTTP Features.
- Select WebDAV Publishing, and then click OK.
Windows Server 2008 or Windows Vista
Download the installation package from the following URL:
Follow the instructions in the following walkthrough to install the WebDAV module:
How To
How to configure WebDAV locking for a Web site
Open Internet Information Services (IIS) Manager:
If you are using Windows Server 2012 or Windows Server 2012 R2:
- On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
If you are using Windows 8 or Windows 8.1:
- Hold down the Windows key, press the letter X, and then click Control Panel.
- Click Administrative Tools, and then double-click 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.
In the Connections pane, expand the server name, expand the Sites node, then click the name of the site.
In the site's Home pane, double-click WebDAV Authoring Rules.
When the WebDAV Authoring Rules page is displayed, click WebDAV Settings in the Actions pane.
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.
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
Attribute | Description |
---|---|
name |
Required attribute. Specifies the name for a lock store provider. |
image |
Required attribute. Specifies the file system path for a lock store provider. Note: On a 64-bit system this will be the 64-bit path, whereas on a 32-bit system this will contain the path to the 32-bit provider and the image32 attribute will be ignored. |
image32 |
Optional attribute. Specifies the 32-bit path for a lock provider on a 64-bit system. Note: This attribute was added in WebDAV 7.5 and IIS 7.5. |
Child Elements
None.
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()