Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Directory.CreateDirectory always fails.

Reply
Thread Tools

Directory.CreateDirectory always fails.

 
 
Wayne Brantley
Guest
Posts: n/a
 
      07-11-2005
Using a webservice in asp.net, I make a call to
Directory.CreateDirectory(@"c:\test") and this works fine.
I can create any directory anywhere on my local machine.

Now, I have an iomega NAS on the network. (There is not a domain). This
drive does NOT use permissions and essentially everyone who can access it
can do anything on it. It maps to my computer as drive 'n:'.

If I use that same webservice and call Directory.CreateDirectory(@"n:\test")
it fails with: Could not find a part of the path "n:\"

I have read every article on this twice and tried everything - nothing
works:

1) I tried using _mkdir, just for kicks -
http://hatka.net/wlogdev/archive/2004/08/29/178.aspx
2) <identity impersonate="true"
3) Impersonation in code -
http://support.microsoft.com/default...N-US;Q306158#4 (Checking
System.Security.Principal.WindowsIdentidy.GetCurre nt().Name before and after
impersonation shows the context changed, but the CreateDirectory fails
anyway.
4) Changing the account aspnet_wp runs under - changed it to system and to
my poweruser account I am using, neither helped.


I wrote a small regular .net application that makes a call to
Directory.CreateDirectory(@"n:\test") and it succeeds, so I know the NAS is
working correctly and it has to be a permissions issue of some kind, but
cannot figure out what.

(Running under XP SP2)


Wayne



 
Reply With Quote
 
 
 
 
Robert Hurlbut [MVP]
Guest
Posts: n/a
 
      07-11-2005
I am not certain (as I haven't tried this yet), but it could be a CAS (Code
Access Security) issue as you are running an intranet site to update what
may look like a network share. What is the exact exception (wording) you are
getting?

Robert Hurlbut
Security Developer MVP


"Wayne Brantley" <> wrote in message
news:...
> Using a webservice in asp.net, I make a call to
> Directory.CreateDirectory(@"c:\test") and this works fine.
> I can create any directory anywhere on my local machine.
>
> Now, I have an iomega NAS on the network. (There is not a domain). This
> drive does NOT use permissions and essentially everyone who can access it
> can do anything on it. It maps to my computer as drive 'n:'.
>
> If I use that same webservice and call
> Directory.CreateDirectory(@"n:\test") it fails with: Could not find a part
> of the path "n:\"
>
> I have read every article on this twice and tried everything - nothing
> works:
>
> 1) I tried using _mkdir, just for kicks -
> http://hatka.net/wlogdev/archive/2004/08/29/178.aspx
> 2) <identity impersonate="true"
> 3) Impersonation in code -
> http://support.microsoft.com/default...N-US;Q306158#4
> (Checking System.Security.Principal.WindowsIdentidy.GetCurre nt().Name
> before and after impersonation shows the context changed, but the
> CreateDirectory fails anyway.
> 4) Changing the account aspnet_wp runs under - changed it to system and
> to my poweruser account I am using, neither helped.
>
>
> I wrote a small regular .net application that makes a call to
> Directory.CreateDirectory(@"n:\test") and it succeeds, so I know the NAS
> is working correctly and it has to be a permissions issue of some kind,
> but cannot figure out what.
>
> (Running under XP SP2)
>
>
> Wayne
>
>
>



 
Reply With Quote
 
 
 
 
Robert Hurlbut [MVP]
Guest
Posts: n/a
 
      07-11-2005
My apologies -- I see the error you mentioned in your question.

I got the same error recently for an application doing something similar.
Even though you may have given everyone permission to the folder/drive, have
you set the permissions on the share settings as well? I believe by default,
the permissions are set to "Read Only".

Robert Hurlbut
Security Developer MVP


"Wayne Brantley" <> wrote in message
news:...
> Using a webservice in asp.net, I make a call to
> Directory.CreateDirectory(@"c:\test") and this works fine.
> I can create any directory anywhere on my local machine.
>
> Now, I have an iomega NAS on the network. (There is not a domain). This
> drive does NOT use permissions and essentially everyone who can access it
> can do anything on it. It maps to my computer as drive 'n:'.
>
> If I use that same webservice and call
> Directory.CreateDirectory(@"n:\test") it fails with: Could not find a part
> of the path "n:\"
>
> I have read every article on this twice and tried everything - nothing
> works:
>
> 1) I tried using _mkdir, just for kicks -
> http://hatka.net/wlogdev/archive/2004/08/29/178.aspx
> 2) <identity impersonate="true"
> 3) Impersonation in code -
> http://support.microsoft.com/default...N-US;Q306158#4
> (Checking System.Security.Principal.WindowsIdentidy.GetCurre nt().Name
> before and after impersonation shows the context changed, but the
> CreateDirectory fails anyway.
> 4) Changing the account aspnet_wp runs under - changed it to system and
> to my poweruser account I am using, neither helped.
>
>
> I wrote a small regular .net application that makes a call to
> Directory.CreateDirectory(@"n:\test") and it succeeds, so I know the NAS
> is working correctly and it has to be a permissions issue of some kind,
> but cannot figure out what.
>
> (Running under XP SP2)
>
>
> Wayne
>
>
>



 
Reply With Quote
 
Wayne Brantley
Guest
Posts: n/a
 
      07-14-2005
Keep in mind this is a NAS that essentially has one built in share and there
are NO permissions that can even be set - the device does not enforce
permissions.

I also tried it to shares that are on a domain, using a domain admin
account - with the same error. Any ideas?

"Robert Hurlbut [MVP]" <> wrote in message
news:%...
> My apologies -- I see the error you mentioned in your question.
>
> I got the same error recently for an application doing something similar.
> Even though you may have given everyone permission to the folder/drive,
> have you set the permissions on the share settings as well? I believe by
> default, the permissions are set to "Read Only".
>
> Robert Hurlbut
> Security Developer MVP
>
>
> "Wayne Brantley" <> wrote in message
> news:...
>> Using a webservice in asp.net, I make a call to
>> Directory.CreateDirectory(@"c:\test") and this works fine.
>> I can create any directory anywhere on my local machine.
>>
>> Now, I have an iomega NAS on the network. (There is not a domain). This
>> drive does NOT use permissions and essentially everyone who can access it
>> can do anything on it. It maps to my computer as drive 'n:'.
>>
>> If I use that same webservice and call
>> Directory.CreateDirectory(@"n:\test") it fails with: Could not find a
>> part of the path "n:\"
>>
>> I have read every article on this twice and tried everything - nothing
>> works:
>>
>> 1) I tried using _mkdir, just for kicks -
>> http://hatka.net/wlogdev/archive/2004/08/29/178.aspx
>> 2) <identity impersonate="true"
>> 3) Impersonation in code -
>> http://support.microsoft.com/default...N-US;Q306158#4
>> (Checking System.Security.Principal.WindowsIdentidy.GetCurre nt().Name
>> before and after impersonation shows the context changed, but the
>> CreateDirectory fails anyway.
>> 4) Changing the account aspnet_wp runs under - changed it to system and
>> to my poweruser account I am using, neither helped.
>>
>>
>> I wrote a small regular .net application that makes a call to
>> Directory.CreateDirectory(@"n:\test") and it succeeds, so I know the NAS
>> is working correctly and it has to be a permissions issue of some kind,
>> but cannot figure out what.
>>
>> (Running under XP SP2)
>>
>>
>> Wayne
>>
>>
>>

>
>



 
Reply With Quote
 
[MSFT]
Guest
Posts: n/a
 
      07-14-2005
I agree with Robert that it may be a CAS issue. You may try to strong-name
the ASP.NET application and set fully trust for the assembly, will this fix
the problem? For more info on CAS:

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcodeaccesssecurity.asp

Luke


 
Reply With Quote
 
Wayne Brantley
Guest
Posts: n/a
 
      08-02-2005
I have now created a class that is called from a console application that
calls Directory.CreateDirectory.
When called from the console all works fine.
I then called it from a service. I had the service logon as the
administrator and it fails with the same error.

Any other ideas?



"[MSFT]" <> wrote in message
news:...
>I agree with Robert that it may be a CAS issue. You may try to strong-name
> the ASP.NET application and set fully trust for the assembly, will this
> fix
> the problem? For more info on CAS:
>
> http://msdn.microsoft.com/library/de...us/cpguide/htm
> l/cpconcodeaccesssecurity.asp
>
> Luke
>
>



 
Reply With Quote
 
[MSFT]
Guest
Posts: n/a
 
      08-02-2005
Hello Wayne,

Have you tried to strong-name your web service and set it full trusted on
the server?

Luke

 
Reply With Quote
 
Wayne Brantley
Guest
Posts: n/a
 
      08-02-2005
I finally got it working. It must be some sort of OS (Windows XP SP2) or
..net bug.

Create directory works on a path like
"\\server\share\folder\folder\folder\folder"

However, if you connect a network drive to "\\server\share", say drive s:
and then try to use CreateDirectory on a path of
"s:\folder\folder\folder\folder" it always gives the errors described.

Can you check into this and see if this issue has been reported?

Wayne

"[MSFT]" <> wrote in message
news:...
> Hello Wayne,
>
> Have you tried to strong-name your web service and set it full trusted on
> the server?
>
> Luke
>



 
Reply With Quote
 
[MSFT]
Guest
Posts: n/a
 
      08-03-2005
It looks still a code access security error, you may try open assembly.cs
in your project and add following code:

using System.Security;
using System.Security.Permissions;

[assembly:FileIOPermission(SecurityAction.RequestMi nimum,Unrestricted=true)]
// Request complete File IO functionality
[assembly:RegistryPermission(SecurityAction.Request Minimum, All="*")]
//Request complet access to the registery key
[assembly:ZoneIdentityPermission(SecurityAction.Req uestMinimum,Zone=Security
Zone.NoZone)] // Request unrestricted zone

These will help your application to require proper permission.

Luke


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wireless Lan on/off switch always litup Terry Wireless Networking 1 08-14-2005 07:15 PM
File copy always interrupted over wireless network =?Utf-8?B?TWF0cml4Y3ViZWQ=?= Wireless Networking 1 02-28-2005 06:00 PM
Why do I always have to repair my network connection after rebooti =?Utf-8?B?Q29uZnVzZWRfQ29uc3VtZXI=?= Wireless Networking 2 11-28-2004 02:24 PM
belkin 54g always works on 11 Mbps hans Wireless Networking 2 11-03-2004 01:17 PM
Trying to create a CSS box that is always is always the width of an image placed inside it (and no wider) Deryck HTML 4 06-22-2004 08:25 PM



Advertisments
 



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