« Previous Next »

Thread: Automating WebDav Authoring Rules

Last post 11-19-2008 10:27 PM by trnsfrmrsr. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 11-17-2008, 6:55 PM

    Automating WebDav Authoring Rules

    I'm faced with migrating a massive file server from iis6 to iis7 (on folder for each of our users to store documents). I've figured out how to programatically migrate data, create virtual directories for each user however, I'm having trouble figuring a good way to add WebDav authoring rules. I'd like to add one authoring rule per virtual directory (more secure than how were currently configured) allowing the folder owner to read, write etc.

    However, so far the only way i see to programatically add authoring rules is to edit the applicationHost.xml and throw in an XML statement for each directory. Is there a good way to go about creating authoring rules (.net class library perhaps?) or am i stuck appending authoring rules to the applicationhost.xml configuration?  If the only good way to go about this is to append to the applicaitonhost.xml is there a best pratice method for appending to the xml file?

     

     

  • 11-18-2008, 6:38 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: Automating WebDav Authoring Rules

    There are many ways to edit IIS configuration - AHAdmin, Microsoft.Web.Administration, appcmd, WMI, powershell - pick whatever works for you.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 11-18-2008, 7:22 PM In reply to

    Re: Automating WebDav Authoring Rules

    I've been playing around with all of the options you've mentioned. I seem to run into issues with actually setting or create the objects needs to set an authoring rule equal to.


    I followed the directions here to use appcmd.exe to try and set the authoring rules up

    http://learn.iis.net/page.aspx/352/how-to-configure-webdav-settings-using-appcmd/

    I exectued the following command:

    PS IIS:\Sites\Default Web Site> appcmd.exe set config "default web site/site123" /section:system.web.webServer/webdav/authoringRules /+[users='domain.net\user123',path='*',access='Read,Write,Source'] /commit:apphost

    It seems that no matter what I do I always get:

    Failed to process input: The parameter 'path=/' must begin with a / or - (HRESULT=80070057).

    Is there any documentation on how to create an authoring rule? and apply it

  • 11-19-2008, 1:07 AM In reply to

    Re: Automating WebDav Authoring Rules

    Could you try:

    appcmd.exe set config "Default Web Site/SilverlightApp" -section:system.webServer/webdav/authoringRules /+"[users='domain.net\user123',path='*',access='Read, Write, Source']" /commit:apphost

    I used Configuration Editor from AdminPack to generate it: http://www.iis.net/extensions/AdministrationPack

  • 11-19-2008, 1:45 PM In reply to

    Re: Automating WebDav Authoring Rules

    thanks for the admin pack reccomendation I used the admin tool to generate an appcmd script, when i run the script.....

    appcmd.exe set config "Default Web Site/site123" -section:system.webServer/webdav/authoringRules /+"[users='domain.net\user123',path='*',access='Read, Write, Source']" /commit:apphost

    Running that command i get back:

    Failed to process input: The parameter 'system.webServer/webdav/authoringRules' must begin with a / or - (HRESULT=80070057). I'm gonna take a stab here and guess that appcmd just doesn't work for this.

  • 11-19-2008, 4:46 PM In reply to

    Re: Automating WebDav Authoring Rules

    Well, this might not be the most elegant solution but I fixed it. I wanted something in powershell so I could go ahead and add this to my migration script. basically I converted the c# script generated by the admin tool.

    thanks everyone for your help

     here it is (if anyone ever uses this, replace site123 with you site and domain.net\user123 with the user your adding):

    [Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")

    $serverManager = new-object microsoft.web.administration.servermanager

    $config = $serverManager.GetApplicationHostConfiguration()

    $authoringRulesSection = $config.GetSection("system.webServer/webdav/authoringRules", "Default Web Site/site123")

    $authoringRulesCollection = [microsoft.web.administration.ConfigurationElementCollection]
    $authoringRulesCollection = $authoringRulesSection.GetCollection()
    $addElement = [microsoft.web.administration.configurationelement]
    $addElement = $authoringRulesCollection.CreateElement("add")
    $addElement.setAttributeValue("users", "domain.net\user123")
    $addElement.setAttributeValue("path", "*")
    $addElement.setAttributeValue("access", "read,write,source")
    $authoringRulesCollection.Add($addElement)
    $serverManager.commitChanges()


     

     

  • 11-19-2008, 7:45 PM In reply to

    Re: Automating WebDav Authoring Rules

     

    That is interesting, are your running Windows Vista RTM? I tried this in Vista SP1 and it worked fine. (using a command prompt)

    I did tried it using PowerShell and it doesnt work, it turns out you need to use quotes aroung the section:

    .\appcmd.exe set config "Default Web Site/site123" "-section:system.webServer/webdav/aut
    horingRules" /+"[users='domain.net\user1234',path='*',access='Read, Write, Source']" /commit:apphost

  • 11-19-2008, 7:58 PM In reply to

    Re: Automating WebDav Authoring Rules

    I'm on server 2008 with the most recent updates.

     I just gave your command another try and it worked!!, this will certainly look (and probably work much better) than the my .net/powershell solution.

    can't believe I didn't think to use quotes around the whole -section option.

     Thanks for your help 

     

  • 11-19-2008, 10:27 PM In reply to

    Re: Automating WebDav Authoring Rules

    With the powershell script (if you can call it that i guess so if you throw it in a file). I found the error. The access section has to have capital Read,Write,Source in it. If a rule is already there for a user it will also fail.

     Shouldn't make a difference, but I've been running it from the IIS powershell provider (extra install).

     Here's a copy of the proper code. I just ran this one (after removing the permission it added earlier, with no issue) anyone should be able to copy and paste this into a powershell command line:

     [Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")

    $serverManager = new-object microsoft.web.administration.servermanager

    $config = $serverManager.GetApplicationHostConfiguration()

    $authoringRulesSection = $config.GetSection("system.webServer/webdav/authoringRules", "Default Web Site/site123")

    $authoringRulesCollection = [microsoft.web.administration.ConfigurationElementCollection]
    $authoringRulesCollection = $authoringRulesSection.GetCollection()
    $addElement = [microsoft.web.administration.configurationelement]
    $addElement = $authoringRulesCollection.CreateElement("add")
    $addElement.setAttributeValue("users", "domain.net\user123")
    $addElement.setAttributeValue("path", "*")

    #the line below is the line that had to be changed

    $addElement.setAttributeValue("access", "Read,Write,Source")
    $authoringRulesCollection.Add($addElement)
    $serverManager.commitChanges()

Page 1 of 1 (9 items)
Microsoft Communities