This project is read-only.

Cannot create virtual directory - Access is denied

Mar 9, 2010 at 11:34 PM

I've done a bit of searching around and have been unable to find a solution that works.

I'm trying to automate deployment of a webapp to IIS.  My environment is as follows:

Server: Windows 2k3 with IIS 6 & .net 3.5 SP1

Dev box: Windows XP pro .net 3.5 SP1 

The user that I'm running my msbuild script from is an admin on the dev box (the box the script is being run on).  The account on the iis server that is being used is THE administrator account.

Here is what my msbuild target looks like:

 

<Target Name="CreateIISVirtualDirectory" >
<MakeDir Directories="$(iisShareLocation)" Condition="!Exists('$(iisShareLocation)')"/>
<!-- Create virtual directory if username/password exists -->
<Web.WebSite.CreateVirtualDirectory
VirtualDirectoryName="$(iisVirtualDirectory)" 
Path="$(iisLocalLocation)"
MachineName="$(iisServer)" 
UncUsername="$(iisUserName)" 
WebSiteName="TestWebapp"
AppPoolID="TestPool1"
UncPassword="$(iisPassword)" Condition="'$(iisUserName)' != '' and '$(iisPassword)' != ''"/>
<!-- Username/password doesn't exist, use localhost -->
<WebDirectoryCreate
VirtualDirectoryName="$(iisVirtualDirectory)" 
VirtualDirectoryPhysicalPath="$(iisLocalLocation)"
MachineName="localhost" 
WebSiteName="$(iisWebSiteName)"
Condition="'$(iisUserName)' == '' or '$(iisPassword)' == ''"/>
</Target>

 

 

	<Target Name="CreateIISVirtualDirectory" >

		<MakeDir Directories="\\iisserver\inetpub\wwwroot\vd" Condition="!Exists('\\iisserver\inetpub\wwwroot\vd')"/>

		<Web.WebSite.CreateVirtualDirectory

			VirtualDirectoryName="vd" 

			Path="c:\inetpub\wwwroot\vd"

			MachineName="iisserver" 

			UncUsername="administrator" 

			UncPassword="admin_password"/>

	</Target>

 

 

When I run this from my box I get the following result from msbuild:
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3603]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 3/9/2010 3:27:13 PM.
Project "c:\projects\iis_deployment\build.xml" on node 0 (CreateIISVirtualDirectory target(s)).
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : A task error has occured.
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : Message               = Access is denied.
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : 
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : VirtualDirectoryName  = vd
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : Path                  = c:\inetpub\wwwroot\vd
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : MachineName           = iisserver
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : WebSiteName           = Default Web Site
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : WebAppName            = <String.Empty>
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AppPoolId             = DefaultAppPool
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AppCreate             = True
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AnonymousUserName     = <String.Empty>
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AnonymousUserPassword = <String.Empty>
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : UncUserName           = administrator
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : UncPassword           = admin_password
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AuthFlags             = <String.Empty>
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : AccessFlags           = <String.Empty>
c:\projects\iis_deployment\common\msbuild.targets(529,3): error : 
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at System.DirectoryServices.DirectoryEntry.Bind()
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at System.DirectoryServices.DirectoryEntry.get_IsContainer()
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container)
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at System.DirectoryServices.DirectoryEntries.GetEnumerator()
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at Microsoft.Sdc.Tasks.Configuration.Web.WebSite.GetIdentifierFromDescription(String machineName, String description)
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at Microsoft.Sdc.Tasks.Configuration.Web.WebSite.Load(String machineName, String description)
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at Microsoft.Sdc.Tasks.Web.WebSite.CreateVirtualDirectory.InternalExecute()
c:\projects\iis_deployment\common\msbuild.targets(529,3): error :    at Microsoft.Sdc.Tasks.TaskBase.Execute()
Done Building Project "c:\projects\iis_deployment\build.xml" (CreateIISVirtualDirectory target(s)) -- FAILED.
Build FAILED.
If I try and change this to deploy to my local IIS instance it works just fine.  At this point, the server is not on the domain, but the dev box is.  However I have tried with both on and off of the domain with the same results.

Any thoughts on what might be going on here?