Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS AppCmd syntax for setting credentials for virtualDirectory

Tags:

iis

appcmd

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>
like image 460
Olle Avatar asked Jan 13 '23 08:01

Olle


1 Answers

This should work:

appcmd set vdir /vdir.name:"EXAMPLESITE/upload" /userName:user /password:password
like image 145
Kev Avatar answered Jan 31 '23 04:01

Kev