# Re: Access a Network Share From ASP.NET

From: silvano paxia (silvano_at_dexelop.com)
Date: 05/22/03

```Date: Thu, 22 May 2003 19:01:12 +0200

```

Solved!!!!

i was using impersonation...

so of course the user was not working properly...

You're really very good!!!

Matjaz i really have no words to thank you

Is really nice when someone helps you and
tomorrow i'll help someone else, this
way the world should become better and better.

Thanks, thanks, thanks

--silvano

"silvano paxia" <silvano@dexelop.com> ha scritto nel messaggio
news:#oyRuSIIDHA.2176@TK2MSFTNGP10.phx.gbl...
> It was executing under IUSR_MACHINE...
>
> How can i enforce the ASPNET User?
>
> THANKS AGAIN
>
> --silvano
> news:eQXFh9HIDHA.672@tk2msftngp13.phx.gbl...
> > Can you post the code that gives you this error ? Does this code work
> localy
> > ? Execute following code
> > string userName = WindowsIdentity.GetCurrent().Name;
> >
> > This will display under which process your code executes.
> >
> > Regards
> >
> >
> > "silvano paxia" <silvano@dexelop.com> wrote in message
> > news:OHnbFyHIDHA.612@TK2MSFTNGP11.phx.gbl...
> >
> > > Please Matjaz something else to try???
> > >
> > > many many thanks
> > >
> > > --silvano
> > > "silvano paxia" <silvano@dexelop.com> ha scritto nel messaggio
> > > news:#UbDogHIDHA.3604@tk2msftngp13.phx.gbl...
> > > > Did exacly what you told me.
> > > >
> > > > and i'm able to log into the webserver
> > > > the Share (write/ Read etc) do everything.
> > > >
> > > > The only problem is that when i execute my code
> > > > from the ASP Page i always get:
> > > >
> > > >
> > > > --silvano
> > > >
> > > > news:#24pbUGIDHA.3084@tk2msftngp13.phx.gbl...
> > > > > Grant (for this one) LogOn localy permission for this accoun in
you
> > > Local
> > > > > Security Policy on your server. This will enable ASPNET to logon.
> > > > >
> > > > > Regards
> > > > >
> > > > > Matjaz Ladava
> > > > >
> > > > > "silvano paxia" <silvano@dexelop.com> wrote in message
> > > > > news:OQLHARGIDHA.2180@TK2MSFTNGP11.phx.gbl...
> > > > > > Hi Matjaz thanks again,
> > > > > >
> > > > > > my server is also my development machine is an
> > > > > > XP Professional.
> > > > > >
> > > > > > When i try to execute
> > > > > >
> > > > > > 2. execute runas /user:ASPNET cmd.exe
> > > > > >
> > > > > > and insert the password i get
> > > > > >
> > > > > > error 1385
> > > > > >
> > > > > > Logon failure: The user has not been granted the requested logon
> > type
> > > at
> > > > > > this computer
> > > > > >
> > > > > > Probably the ASPNET user has really limited permissions
> > > > > > i need to enhance.
> > > > > >
> > > > > > Little more help please and we're done...
> > > > > >
> > > > > > thanks
> > > > > >
> > > > > > --silvano
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > "Matjaz Ladava" <matjaz@_nospam_ladava.com> ha scritto nel
> messaggio
> > > > > > news:#7pCl6FIDHA.2152@TK2MSFTNGP10.phx.gbl...
> > > > > > > If you have correctly followed instructions on creating custom
> > > ASPNET
> > > > > > > password and hardcoded it into machine.config, then it should
> > work.
> > > Is
> > > > > the
> > > > > > > server also your development machine ?
> > > > > > > Normaly i use following procedure to test this.
> > > > > > >
> > > > > > > 1. Go into command prompt on the server, that is hosting
> > application
> > > > > which
> > > > > > > is trying to acces another share
> > > > > > > 2. execute runas /user:ASPNET cmd.exe
> > > > > > > 3. System will prompt you for a password. Enter password, that
> was
> > > set
> > > > > for
> > > > > > > local ASPNET account
> > > > > > > 4. You should now have command prompt window running as ASPNET
> > > account
> > > > > > > 5. Try net view \\otherserver or dir\\otherserver\sharename
> > > > > > > 6. If you het access denied, then you have problem with
> ACL/SHARE
> > > > > settings
> > > > > > > on remote server.
> > > > > > > 7. Go there and check share permissions and file permissions
> > > > > > > 8. That is all
> > > > > > > 9. You can try runas allso on remote server to verify that you
> can
> > > > logon
> > > > > > and
> > > > > > > do stuff there.
> > > > > > >
> > > > > > > Hope this helps a little.
> > > > > > >
> > > > > > > Regards
> > > > > > >
> > > > > > > Matjaz Ladava
> > > > > > >
> > > > > > > "silvano paxia" <silvano@dexelop.com> wrote in message
> > > > > > > news:O%232NOpFIDHA.3604@tk2msftngp13.phx.gbl...
> > > > > > > > Sorry Matjaz if i bother you again
> > > > > > > > using the runas commad the aspnet user
> > > > > > > > does not have permissions to open notepad
> > > > > > > > to open the computer manager etc.
> > > > > > > >
> > > > > > > > How can i estend the permissions?
> > > > > > > >
> > > > > > > > Also i want to tell you that i'm using the mirrored accounts
> > > > > > > > (created an ASPNET account in the server with the same
> > > > > > > > password) but nothing.
> > > > > > > >
> > > > > > > > Thanks again for your help.
> > > > > > > >
> > > > > > > > --silvano
> > > > > > > >
> > > > > > > > "Matjaz Ladava" <matjaz@_nospam_ladava.com> ha scritto nel
> > > messaggio
> > > > > > > > news:um6cGDFIDHA.2216@TK2MSFTNGP11.phx.gbl...
> > > > > > > > > one way would be to log on as ASPNET account and try to
> access
> > > the
> > > > > > > share.
> > > > > > > > > You can use runas command to try this.
> > > > > > > > >
> > > > > > > > > Regards
> > > > > > > > >
> > > > > > > > > Matjaz Ladava
> > > > > > > > >
> > > > > > > > > "silvano paxia" <silvano@dexelop.com> wrote in message
> > > > > > > > > news:usVma7EIDHA.1572@tk2msftngp13.phx.gbl...
> > > > > > > > > > Thanks MatJaz!
> > > > > > > > > >
> > > > > > > > > > How can i check if the .Net Account has permission
> > > > > > > > > > to access the share?
> > > > > > > > > >
> > > > > > > > > > Many Thanks
> > > > > > > > > >
> > > > > > > > > > --silvano
> > > > > > > > > >
> > > > > > > > > > "Matjaz Ladava" <matjaz@_nospam_ladava.com> ha scritto
nel
> > > > > messaggio
> > > > > > > > > > news:eXs\$r2EIDHA.1608@tk2msftngp13.phx.gbl...
> > > > > > > > > > > This means, that your .NET account doesn't have
> permission
> > > to
> > > > > > acess
> > > > > > > > the
> > > > > > > > > > > share. Are you in domain enviroment ? If yes try with
> > > > > > impersonation.
> > > > > > > > If
> > > > > > > > > > no,
> > > > > > > > > > > then you must doublecheck your mirrored accounts.
> > > > > > > > > > >
> > > > > > > > > > > Allso read
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetch08.asp?frame=t
> > > > > > > > > > rue
> > > > > > > > > > > which has info about how to acieve that.
> > > > > > > > > > >
> > > > > > > > > > > Regards
> > > > > > > > > > >
> > > > > > > > > > > Matjaz Ladava
> > > > > > > > > > >
> > > > > > > > > > > "silvano paxia" <silvano@dexelop.com> wrote in message
> > > > > > > > > > > news:%23gUwsnEIDHA.2080@tk2msftngp13.phx.gbl...
> > > > > > > > > > > > Thank Matjaz,
> > > > > > > > > > > >
> > > > > > > > > > > > I change to the UNC path and know the message is
> > > > > > > > > > > >
> > > > > > > > > > > > Access Denied!
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > thanks
> > > > > > > > > > > >
> > > > > > > > > > > > --silvano
> > > > > > > > > > > >
> > > > > > > > > > > > "Matjaz Ladava" <matjaz@_nospam_ladava.com> ha
scritto
> > nel
> > > > > > > messaggio
> > > > > > > > > > > > news:#681H68HDHA.2068@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > > > > > ASP account knows nothing about drive T, you have
to
> > use
> > > > UNC
> > > > > > > paths
> > > > > > > > > in
> > > > > > > > > > > the
> > > > > > > > > > > > > form of \\servername\sharename\....
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards
> > > > > > > > > > > > >
> > > > > > > > > > > > > Matjaz Ladava
> > > > > > > > > > > > >
> > > > > > > > > > > > > "silvano paxia" <silvano@dexelop.com> wrote in
> message
> > > > > > > > > > > > > news:eV\$3Q18HDHA.3260@tk2msftngp13.phx.gbl...
> > > > > > > > > > > > > > Hi,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > i need to access (read/write) a file server from
> > > > > > > > > > > > > > my asp.net application.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The two machines are not in a domain but
> > > > > > > > > > > > > > a workgroup.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Even if i followed the msdn instructions
creating
> > > > > > > > > > > > > > the mirrored accounts:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 1) Set password for ASPNET
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 2) Hardcoded password in machine.config
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > 3) created an ASPNET account in the file server
> > having
> > > > > > > > > > > > > > the same password as 1)
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing...
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Always the same error message:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Could not find a part of the path for
> > > > > > "T:\banners\banner1.jpg"
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --silvano
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>