IIS AppCmd syntax for setting credentials for virtualDirectory

白昼怎懂夜的黑 提交于 2019-12-13 13:15:03

问题


I'm using appcmd to create a new virtual directory in IIS8. The syntax for this is:

appcmd add vdir /app.name:<NAME> /path:<PATH> /physicalPath:<PHYSICAL-PATH>

This works fine. Now I need to set some credentials; this is easy in the GUI (virtual dir > basic settings > connect as). When I set this, I can see in my applicationHost.config file that it is updating an XML entry. So I should be able to set that manually with appcmd. I'm struggling with the syntax to navigate to the right XML element so I can set the attribute userName and add the attribute password.

Here is my XML:

<sites>
  <site name="EXAMPLESITE" id="4">
    <application path="/" applicationPool="EXAMPLEPOOL">
        <virtualDirectory path="/" physicalPath="c:\wwwroot\" userName="" />
        <virtualDirectory path="/upload" physicalPath="\\SOME-COMPUTER-ON-NETWORK\upload" userName="" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:80" />
    </bindings>
  </site>
</sites>

回答1:


This should work:

appcmd set vdir /vdir.name:"EXAMPLESITE/upload" /userName:user /password:password


来源:https://stackoverflow.com/questions/18912419/iis-appcmd-syntax-for-setting-credentials-for-virtualdirectory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!