<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Coffeehouse - ASP.NET and Network Drives Help</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Coffeehouse - ASP.NET and Network Drives Help</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Wed, 19 Jun 2013 18:38:38 GMT</pubDate>
	<lastBuildDate>Wed, 19 Jun 2013 18:38:38 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>3</c9:totalResults>
	<c9:pageCount>-3</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Coffeehouse - ASP.NET and Network Drives Help</title>
		<description><![CDATA[<p>Hey guys,</p><p>So I have another problem. I need to check out a file from PVCS from an ASP.NET webpage. In order to do so I spawn a process that calls a batch file which sets some environment variables and then calls the pvcs command get.exe to get the file. This all works great when I run it on my local machine, but as soon as I deploy to the server all hell breaks lose. The website impersonates the main user, this happens in the web.config (still not sure if relevant).&nbsp;</p><p>After trial and error, I narrowed down the problem to communication with shared drives. PVCS drive is mapped in the server. So I made a small batch script that only does a cd to a directory on this shared drive and it failed. Code is simply &quot;<strong>cd Z:/work/</strong>&quot;.</p><p>Google gave some answers and more questions still. Apparently impersonation and shared drives simply do not work. But I'm not certain if that pertains to spawned process using C# Process class. Though, given that the webpage works perfectly in my machine without impersonation, this might have something to do with it. C# spawned processes have limited permissions, but I don't think this is the problem since my code is failing in doing a simple&nbsp;<strong>cd Z:\work\.&nbsp;</strong></p><p>So I created a console app which does the check out (same code as the webpage) and it worked in the web server without a problem. The problem only occurs when I spawned the process from the webpage in the webserver. I made some dummy code to test.</p><p>I even tried to call the console app from the website, but that still doesn't work.&nbsp;</p><p>&nbsp;</p><p><pre class="brush: csharp">public partial class _Default : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            

        }

        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            Command cmd = new Command(@&quot;cmd&quot;, @&quot;/c testpath.bat&quot;);
            cmd.execute();
          
            lblError.Text = cmd.stderr;
            lblOutput.Text = cmd.stdout;
        }
    }


public class Command
    {
        // Private members
        private Process process;
        private int timeout;

        // Public members
        public string stderr { get; private set; }
        public string stdout { get; private set; }
        public string exception { get; private set; }
        public bool done { get; private set; }
        public int exitLevel { get; private set; }


        /// &lt;summary&gt;
        /// Construct a Command object that will be executed in a Windows environment.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;args&quot;&gt;the command to execute in command prompt&lt;/param&gt;
        /// &lt;param name=&quot;timeout&quot;&gt;This is optional and consists of the time in milliseconds to wait for the command to finish. Default is 10 seconds.&lt;/param&gt;
        public Command(string exec, string args, string workingDir=&quot;&quot;, int timeout = 5000)
        {
            this.timeout = timeout;
            this.exception = &quot;&quot;;
            process = new Process();
            if (!string.IsNullOrEmpty(workingDir))
                process.StartInfo.WorkingDirectory = workingDir;
            process.StartInfo.FileName = exec;
            process.StartInfo.Arguments = args;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.OutputDataReceived &#43;= process_OutputDataReceived;
        }

        void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Data))
            {
                stdout = e.Data;
            }
        }

        public void execute()
        {
            try
            {
                process.Start();
                process.BeginOutputReadLine();                  // Note that the following three lines in any 
                stderr = process.StandardError.ReadToEnd();     // other order will deadlock. 
                process.WaitForExit(timeout);
            }
            catch (Exception e)
            {
                exception = e.Message;
                Debug.WriteLine(e.Message &#43; &quot;\n&quot; &#43; e.StackTrace);
            }
            Thread.Sleep(1000);
        }

       
    }</pre></p><p>&nbsp;</p><p>Does anybody have any clue what my problem is?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/8ab1217154ea40f9a534a16b01575bcb#8ab1217154ea40f9a534a16b01575bcb</link>
		<pubDate>Wed, 20 Feb 2013 20:50:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/8ab1217154ea40f9a534a16b01575bcb#8ab1217154ea40f9a534a16b01575bcb</guid>
		<dc:creator>pavone</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/pavone/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - ASP.NET and Network Drives Help</title>
		<description><![CDATA[<p>instead of mapped drives, can you use fqdn?</p><p>&nbsp;</p><p>the who is the app pool identity running under?</p><p>&nbsp;</p><p>*edit*</p><p>also, which user are you intending to have access to the shared drive? the impersonated end-user? network service? the app pool identity? you have to decide this first and verify those permissions on the shared folder. if your intention is the impersonated end-user you may have to set up delegation/kerberos for multi-hop credential passing.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/d0d92e58f6014fe5b03ea16b015f5122#d0d92e58f6014fe5b03ea16b015f5122</link>
		<pubDate>Wed, 20 Feb 2013 21:19:06 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/d0d92e58f6014fe5b03ea16b015f5122#d0d92e58f6014fe5b03ea16b015f5122</guid>
		<dc:creator>itsnotabug</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/itsnotabug/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Coffeehouse - ASP.NET and Network Drives Help</title>
		<description><![CDATA[<p>Mapped drives are specific to a logged in user, so that's not going to work, as impersonation doesn't log in a user in such a way that drives map.</p><p>Also impersonation doesn't &quot;hop&quot; over a process boundary, so when you try to access a remote resource impersonation will not escape to that connection.</p><p>So, rather than trying to run the PVCS command line (I am seriously shocked people still use PVCS!) you could try an SDK if they offer one?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/35d0b1e4037544f5b2e3a16b0169cdc4#35d0b1e4037544f5b2e3a16b0169cdc4</link>
		<pubDate>Wed, 20 Feb 2013 21:57:17 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Coffeehouse/ASPNET-and-Network-Drives-Help/35d0b1e4037544f5b2e3a16b0169cdc4#35d0b1e4037544f5b2e3a16b0169cdc4</guid>
		<dc:creator>blowdart</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/blowdart/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>