CreateDirectory working inconsistantly from ASP.net

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default CreateDirectory working inconsistantly from ASP.net

    Please HELP !!

    I have a web page that is trying to create folders on a file server

    eg. \\SERVERNAME\F4\Projects\[New Folder Name]

    Users of the web site are authenticated with Windows Integrated Security.

    (have tried on W2003/IIS6 and W2k/IIS5 with no difference in behavoir)

    When a user connects to the using a browser on the same machine as the
    webserver the code works and is able to create the new folder.

    When the same user connects from a remote machine the CreateDirectory
    function generates the following Exception
    System.UnauthorizedAccessException
    "Access to the path \"TEST\" is denied."
    Source "mscorlib"
    StackTrace
    System.IO.__Error.WinIOError(Int32 errorCode, String str)
    at System.IO.Directory.InternalCreateDirectory(String fullPath, String
    path)\r\n
    ....

    I have tried to do this in 3 ways all with the same problem;
    A)
    DirectoryInfo di = Directory.CreateDirectory(newfullpath);

    B)
    DirectoryInfo root = new DirectoryInfo(rootPath);
    DirectoryInfo di = root.CreateSubdirectory(folderName);

    C)
    [DllImport("kernel32.dll")]
    static extern bool CreateDirectory(string lpPathName, IntPtr
    lpSecurityAttributes);
    ....
    bool result = CreateDirectory(path, IntPtr.Zero);
    DirectoryInfo di = DirectoryInfo(path);

    I have also checked that the Integrated Authentication is getting passed
    correcty into the application

    string origID = Thread.CurrentPrincipal.Identity.Name;
    string contextUser = HttpContext.Current.User.Identity.Name;

    Both call return the same user regardless if the call is from the server or
    a remote machine.
    Needless to say that the User has the required permissions to create the
    folder because they are able to do so as long as they do it from a browser on
    the server itself.

    If anyone can shed any light on what is going on here I would greatly
    appreciate it.

    Regards,
    David Davies
    Goldman Sachs


    David Davies Guest

  2. Similar Questions and Discussions

    1. #38816 [Opn]: PHP code that was working perfectly recently stopped working.
      ID: 38816 User updated by: mtoohee at gmail dot com -Summary: PHP code that was working perfectly recently stopped....
    2. Macromedia Flash Player installed and working properly suddenlys stops working..
      No idea what has caused the Flash player to stop working. This is not my machine but a relatives who has asked for help over the T'giving...
    3. Data not working on Label but is working in Datagrid
      I am creating a simple website in Flex. I want to show different content from the database for home, about us, contact us, etc. I am using a CFC as...
    4. Directory.CreateDirectory() throwing DirectoryNotFound exception for //server/share path
      Hello, I am creating an ASP.NET web service with VB, and I need to be able to create a directory on a network share. When I attempt to create...
    5. Working TableStyle Not Working on a Second DataGrid
      I am having difficulty getting Tablestyles to work on a datagrid. I have 2 datasets, 1 filled and the other not. The first contains customer, stock...
  3. #2

    Default Re: CreateDirectory working inconsistantly from ASP.net

    Hi David:

    You are facing the dreaded double hop NTLM issue. With integrated
    authentication the client's credentials can make exactly one network
    hop. When the browser authenticates to the web server from a remote
    machine the credentials make one hop and can't be used to make a
    second hop to the server with the file share (if the browser is on the
    same machine as the web server the call works because there is still
    only one hop involved).

    A few of the solutions are:

    1) Enable delegation
    [url]http://support.microsoft.com/default.aspx?kbid=810572[/url]

    2) Impersonate with a specific username and password, i.e.
    <identity impersonate="true" userName="<name>" password="<password>"/>
    You can also do this programatically.

    3) Run the ASP.NET worker process under a domain account with
    permissions on both machines.

    There are some good tips for 2 & 3 here:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetch08.asp[/url]

    HTH,

    --
    Scott
    [url]http://www.OdeToCode.com/blogs/scott/[/url]

    On Sun, 24 Oct 2004 20:51:02 -0700, David Davies
    <DavidDavies@discussions.microsoft.com> wrote:
    >Please HELP !!
    >
    >I have a web page that is trying to create folders on a file server
    >
    > eg. \\SERVERNAME\F4\Projects\[New Folder Name]
    >
    >Users of the web site are authenticated with Windows Integrated Security.
    >
    >(have tried on W2003/IIS6 and W2k/IIS5 with no difference in behavoir)
    >
    >When a user connects to the using a browser on the same machine as the
    >webserver the code works and is able to create the new folder.
    >
    >When the same user connects from a remote machine the CreateDirectory
    >function generates the following Exception
    >System.UnauthorizedAccessException
    >"Access to the path \"TEST\" is denied."
    >Source "mscorlib"
    >StackTrace
    >System.IO.__Error.WinIOError(Int32 errorCode, String str)
    >at System.IO.Directory.InternalCreateDirectory(String fullPath, String
    >path)\r\n
    >...
    >
    >I have tried to do this in 3 ways all with the same problem;
    >A)
    >DirectoryInfo di = Directory.CreateDirectory(newfullpath);
    >
    >B)
    >DirectoryInfo root = new DirectoryInfo(rootPath);
    >DirectoryInfo di = root.CreateSubdirectory(folderName);
    >
    >C)
    >[DllImport("kernel32.dll")]
    >static extern bool CreateDirectory(string lpPathName, IntPtr
    >lpSecurityAttributes);
    >...
    >bool result = CreateDirectory(path, IntPtr.Zero);
    >DirectoryInfo di = DirectoryInfo(path);
    >
    >I have also checked that the Integrated Authentication is getting passed
    >correcty into the application
    >
    >string origID = Thread.CurrentPrincipal.Identity.Name;
    >string contextUser = HttpContext.Current.User.Identity.Name;
    >
    >Both call return the same user regardless if the call is from the server or
    >a remote machine.
    >Needless to say that the User has the required permissions to create the
    >folder because they are able to do so as long as they do it from a browser on
    >the server itself.
    >
    >If anyone can shed any light on what is going on here I would greatly
    >appreciate it.
    >
    >Regards,
    >David Davies
    >Goldman Sachs
    >
    Scott Allen Guest

  4. #3

    Default Re: CreateDirectory working inconsistantly from ASP.net

    Many thanks Scott.

    2 and 3 are no feasable becasue the ability to create a directory must
    depend on the rights of the user.

    That leaves Delegation as the only option, I have followed the instructions
    in the kb you posted and waited a few hours to allow for propogation but it
    is still producing the same result.

    Is there any way to test Delegation is functioning ?

    Regards,
    David

    "Scott Allen" wrote:
    > Hi David:
    >
    > You are facing the dreaded double hop NTLM issue. With integrated
    > authentication the client's credentials can make exactly one network
    > hop. When the browser authenticates to the web server from a remote
    > machine the credentials make one hop and can't be used to make a
    > second hop to the server with the file share (if the browser is on the
    > same machine as the web server the call works because there is still
    > only one hop involved).
    >
    > A few of the solutions are:
    >
    > 1) Enable delegation
    > [url]http://support.microsoft.com/default.aspx?kbid=810572[/url]
    >
    > 2) Impersonate with a specific username and password, i.e.
    > <identity impersonate="true" userName="<name>" password="<password>"/>
    > You can also do this programatically.
    >
    > 3) Run the ASP.NET worker process under a domain account with
    > permissions on both machines.
    >
    > There are some good tips for 2 & 3 here:
    > [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetch08.asp[/url]
    >
    > HTH,
    >
    > --
    > Scott
    > [url]http://www.OdeToCode.com/blogs/scott/[/url]
    >
    > On Sun, 24 Oct 2004 20:51:02 -0700, David Davies
    > <DavidDavies@discussions.microsoft.com> wrote:
    >
    > >Please HELP !!
    > >
    > >I have a web page that is trying to create folders on a file server
    > >
    > > eg. \\SERVERNAME\F4\Projects\[New Folder Name]
    > >
    > >Users of the web site are authenticated with Windows Integrated Security.
    > >
    > >(have tried on W2003/IIS6 and W2k/IIS5 with no difference in behavoir)
    > >
    > >When a user connects to the using a browser on the same machine as the
    > >webserver the code works and is able to create the new folder.
    > >
    > >When the same user connects from a remote machine the CreateDirectory
    > >function generates the following Exception
    > >System.UnauthorizedAccessException
    > >"Access to the path \"TEST\" is denied."
    > >Source "mscorlib"
    > >StackTrace
    > >System.IO.__Error.WinIOError(Int32 errorCode, String str)
    > >at System.IO.Directory.InternalCreateDirectory(String fullPath, String
    > >path)\r\n
    > >...
    > >
    > >I have tried to do this in 3 ways all with the same problem;
    > >A)
    > >DirectoryInfo di = Directory.CreateDirectory(newfullpath);
    > >
    > >B)
    > >DirectoryInfo root = new DirectoryInfo(rootPath);
    > >DirectoryInfo di = root.CreateSubdirectory(folderName);
    > >
    > >C)
    > >[DllImport("kernel32.dll")]
    > >static extern bool CreateDirectory(string lpPathName, IntPtr
    > >lpSecurityAttributes);
    > >...
    > >bool result = CreateDirectory(path, IntPtr.Zero);
    > >DirectoryInfo di = DirectoryInfo(path);
    > >
    > >I have also checked that the Integrated Authentication is getting passed
    > >correcty into the application
    > >
    > >string origID = Thread.CurrentPrincipal.Identity.Name;
    > >string contextUser = HttpContext.Current.User.Identity.Name;
    > >
    > >Both call return the same user regardless if the call is from the server or
    > >a remote machine.
    > >Needless to say that the User has the required permissions to create the
    > >folder because they are able to do so as long as they do it from a browser on
    > >the server itself.
    > >
    > >If anyone can shed any light on what is going on here I would greatly
    > >appreciate it.
    > >
    > >Regards,
    > >David Davies
    > >Goldman Sachs
    > >
    >
    >
    David Davies Guest

  5. #4

    Default Re: CreateDirectory working inconsistantly from ASP.net

    Hi David:

    I know of a troubleshooting paper:

    Troubleshooting Kerberos Delegation
    [url]http://www.microsoft.com/downloads/details.aspx?FamilyID=99b0f94f-e28a-4726-bffe-2f64ae2f59a2&displaylang=en[/url]

    It's quite extensive (lengthy) and includes links to some command line
    utilities and demonstrates how to turn on some auditing. Hopefully
    this can help out.

    --
    Scott
    [url]http://www.OdeToCode.com/blogs/scott/[/url]


    On Mon, 25 Oct 2004 20:27:02 -0700, David Davies
    <DavidDavies@discussions.microsoft.com> wrote:
    >Many thanks Scott.
    >
    >2 and 3 are no feasable becasue the ability to create a directory must
    >depend on the rights of the user.
    >
    >That leaves Delegation as the only option, I have followed the instructions
    >in the kb you posted and waited a few hours to allow for propogation but it
    >is still producing the same result.
    >
    >Is there any way to test Delegation is functioning ?
    >
    >Regards,
    >David
    >
    >"Scott Allen" wrote:
    >
    Scott Allen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139