473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Network access from ASPNET user

Is there any other [simple] solution for an ASPNET application to access
network resources other than running as SYSTEM, using delegation (a
nightmare to get to work) or the COM+ solution? I cannot seem to impersonate
a user and obtain network credentials using the DuplicateTokenEx call with
appropriate parameters even though the call seems to not fail. I check my
identity has changed but can only still do local commands.

I would consider running CreateProcessWithLogonW after impersonating an
admin if I could reliably supply stdin and capture stdout and stderr but
can't figure out how to do this in .NET though have done something similar
with standard I/O streams and CreateProcess in a C++ OCX control before.

Main idea is do be able to display network related command output in an
Intranet web page and still maintain reasonable security on the internal
server.

CreateProcessWithLogonW would be the ticket if I could impersonate an Admin
w/o network credentials and then could capture the process' output.

Thanks for any ideas or samples,
Dave

Nov 18 '05 #1
5 3078
the token you duplicate must be a primary token if you want to use it for
network access. if you are impersonating the iis user, they must use basic
authentication (which results in a primary token) or digest which gives a
token that supports delegation (if delegation is turned on).

if you have a standard domain login & password you want to use, you can use
them to create a primary token, though you migh as well set the login &
password in the web config.
-- bruce (sqlwork.com)

"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OS**************@tk2msftngp13.phx.gbl...
Is there any other [simple] solution for an ASPNET application to access
network resources other than running as SYSTEM, using delegation (a
nightmare to get to work) or the COM+ solution? I cannot seem to impersonate a user and obtain network credentials using the DuplicateTokenEx call with
appropriate parameters even though the call seems to not fail. I check my
identity has changed but can only still do local commands.

I would consider running CreateProcessWithLogonW after impersonating an
admin if I could reliably supply stdin and capture stdout and stderr but
can't figure out how to do this in .NET though have done something similar
with standard I/O streams and CreateProcess in a C++ OCX control before.

Main idea is do be able to display network related command output in an
Intranet web page and still maintain reasonable security on the internal
server.

CreateProcessWithLogonW would be the ticket if I could impersonate an Admin w/o network credentials and then could capture the process' output.

Thanks for any ideas or samples,
Dave

Nov 18 '05 #2
When using Windows Authentication with ASPNET and using either <identity
user= pw=/> on web.config or programatically via LogonUser/DuplicateTokenEx
I do not get a token with network credentials as I can only do things on my
own machine. I use a combination of these calls asking for full access and a
primary token successfully and still get all network access denied. I check
that I have successfully switched identities by printing them out. Dave

"bruce barker" <no***********@safeco.com> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
the token you duplicate must be a primary token if you want to use it for
network access. if you are impersonating the iis user, they must use basic
authentication (which results in a primary token) or digest which gives a
token that supports delegation (if delegation is turned on).

if you have a standard domain login & password you want to use, you can use them to create a primary token, though you migh as well set the login &
password in the web config.
-- bruce (sqlwork.com)

"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OS**************@tk2msftngp13.phx.gbl...
Is there any other [simple] solution for an ASPNET application to access
network resources other than running as SYSTEM, using delegation (a
nightmare to get to work) or the COM+ solution? I cannot seem to

impersonate
a user and obtain network credentials using the DuplicateTokenEx call with appropriate parameters even though the call seems to not fail. I check my identity has changed but can only still do local commands.

I would consider running CreateProcessWithLogonW after impersonating an
admin if I could reliably supply stdin and capture stdout and stderr but
can't figure out how to do this in .NET though have done something similar with standard I/O streams and CreateProcess in a C++ OCX control before.

Main idea is do be able to display network related command output in an
Intranet web page and still maintain reasonable security on the internal
server.

CreateProcessWithLogonW would be the ticket if I could impersonate an

Admin
w/o network credentials and then could capture the process' output.

Thanks for any ideas or samples,
Dave


Nov 18 '05 #3
Dave,
You can access network resources of another machine using
impersonation.
Follow this procedure :

* Create a windows user on the web server you are
using(your machine),call it eg: netuser1.
* In the Web.Config file of your ASP.NET application,
<system.web>
<identity impersonate="true" />
</system.web>

Then create a user with the same name netuser1 with the same password on
the machine on the network and give access
to this user for the resource you want to access.(For eg: give security
permission,read,write etc. to the folder on that machine).
You can put the user name and pasword in the identity part in the
Web.config but that is not secure.
So it will be secure to put the impersonate user name and password on the
directory security of virtual directory of iis.
For eg : in iis 5.0 in Windows 2000,

* Right click on the virtual directory
* Goto directory security tab and click on the first EDIT button for
anonymous access and authentication control.
Click on the EDIT of anonymous access,click Browse and change the user
name and password to netuser1 and its password.
Now you can access the network
resource..

For eg :
You can access the file on another machine
string filename="\\\\ip addres of the
machine\\sharename$\\foldername\file1.txt;

StreamReader oSR=new StreamReader(filename);
and loop through it to get the information on that file.
Hope this helps..
Regards,
Marshal Antony
http://dotnetmarshal.com


"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
When using Windows Authentication with ASPNET and using either <identity
user= pw=/> on web.config or programatically via LogonUser/DuplicateTokenEx I do not get a token with network credentials as I can only do things on my own machine. I use a combination of these calls asking for full access and a primary token successfully and still get all network access denied. I check that I have successfully switched identities by printing them out. Dave

"bruce barker" <no***********@safeco.com> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl...
the token you duplicate must be a primary token if you want to use it for
network access. if you are impersonating the iis user, they must use basic authentication (which results in a primary token) or digest which gives a token that supports delegation (if delegation is turned on).

if you have a standard domain login & password you want to use, you can
use
them to create a primary token, though you migh as well set the login
& password in the web config.
-- bruce (sqlwork.com)

"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OS**************@tk2msftngp13.phx.gbl...
Is there any other [simple] solution for an ASPNET application to access network resources other than running as SYSTEM, using delegation (a
nightmare to get to work) or the COM+ solution? I cannot seem to

impersonate
a user and obtain network credentials using the DuplicateTokenEx call with appropriate parameters even though the call seems to not fail. I
check
my identity has changed but can only still do local commands.

I would consider running CreateProcessWithLogonW after impersonating
an admin if I could reliably supply stdin and capture stdout and stderr but can't figure out how to do this in .NET though have done something similar with standard I/O streams and CreateProcess in a C++ OCX control before.
Main idea is do be able to display network related command output in an Intranet web page and still maintain reasonable security on the internal server.

CreateProcessWithLogonW would be the ticket if I could impersonate

an Admin
w/o network credentials and then could capture the process' output.

Thanks for any ideas or samples,
Dave



Nov 18 '05 #4

Marshal, This solution does not work for me as I am not in a position to add
a local user to all the machines and resources I need access to from my web
app and I also need Windows authentication to happen. I need to be able to
impersonate a particular domain user that already has access to the machines
in question and that if I do a local RunAs works fine. Thanks though, Dave

P.S. I have a working class that can execute commands (.NET Process object)
and do impersonation (Logon/DuplicateTokenEx) and capture output but it does
not manage to actually get network credentials for the domain user being
impersonated even though I ask for them and the DuplicateTokenEx seems to
work fine.

Dave
"Marshal Antony" <ma***********@yahoo.com> wrote in message
news:#n**************@TK2MSFTNGP10.phx.gbl...
Dave,
You can access network resources of another machine using
impersonation.
Follow this procedure :

* Create a windows user on the web server you are
using(your machine),call it eg: netuser1.
* In the Web.Config file of your ASP.NET application,
<system.web>
<identity impersonate="true" />
</system.web>

Then create a user with the same name netuser1 with the same password on
the machine on the network and give access
to this user for the resource you want to access.(For eg: give security
permission,read,write etc. to the folder on that machine).
You can put the user name and pasword in the identity part in the
Web.config but that is not secure.
So it will be secure to put the impersonate user name and password on the directory security of virtual directory of iis.
For eg : in iis 5.0 in Windows 2000,

* Right click on the virtual directory
* Goto directory security tab and click on the first EDIT button for
anonymous access and authentication control.
Click on the EDIT of anonymous access,click Browse and change the user
name and password to netuser1 and its password.
Now you can access the network
resource..

For eg :
You can access the file on another machine
string filename="\\\\ip addres of the
machine\\sharename$\\foldername\file1.txt;

StreamReader oSR=new StreamReader(filename);
and loop through it to get the information on that file.
Hope this helps..
Regards,
Marshal Antony
http://dotnetmarshal.com

"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
> When using Windows Authentication with ASPNET and using either <identity
> user= pw=/> on web.config or programatically via LogonUser/DuplicateTokenEx
> I do not get a token with network credentials as I can only do things on my
> own machine. I use a combination of these calls asking for full access and a
> primary token successfully and still get all network access denied. I

check
> that I have successfully switched identities by printing them out.

Dave >
>
> "bruce barker" <no***********@safeco.com> wrote in message
> news:OG**************@TK2MSFTNGP12.phx.gbl...
> > the token you duplicate must be a primary token if you want to use it for > > network access. if you are impersonating the iis user, they must use basic > > authentication (which results in a primary token) or digest which gives a > > token that supports delegation (if delegation is turned on).
> >
> > if you have a standard domain login & password you want to use, you can
> use
> > them to create a primary token, though you migh as well set the
login & > > password in the web config.
> >
> >
> > -- bruce (sqlwork.com)
> >
> >
> >
> > "Dave Kolb" <Da**************@remove.sas.com> wrote in message
> > news:OS**************@tk2msftngp13.phx.gbl...
> > > Is there any other [simple] solution for an ASPNET application to access > > > network resources other than running as SYSTEM, using delegation
(a > > > nightmare to get to work) or the COM+ solution? I cannot seem to
> > impersonate
> > > a user and obtain network credentials using the DuplicateTokenEx
call
> with
> > > appropriate parameters even though the call seems to not fail. I

check
> my
> > > identity has changed but can only still do local commands.
> > >
> > > I would consider running CreateProcessWithLogonW after impersonating an > > > admin if I could reliably supply stdin and capture stdout and
stderr
but > > > can't figure out how to do this in .NET though have done something > similar
> > > with standard I/O streams and CreateProcess in a C++ OCX control before. > > >
> > > Main idea is do be able to display network related command output
in an > > > Intranet web page and still maintain reasonable security on the internal > > > server.
> > >
> > > CreateProcessWithLogonW would be the ticket if I could impersonate an > > Admin
> > > w/o network credentials and then could capture the process'

output. > > >
> > > Thanks for any ideas or samples,
> > > Dave
> > >
> > >
> > >
> >
> >

>
>


Nov 18 '05 #5
Dave,

Read this which may help you :
http://www.netomatix.com/ImpersonateUser.aspx

Regards,
Marshal Antony
http://dotnetmarshal.com
"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

Marshal, This solution does not work for me as I am not in a position to add a local user to all the machines and resources I need access to from my web app and I also need Windows authentication to happen. I need to be able to impersonate a particular domain user that already has access to the machines in question and that if I do a local RunAs works fine. Thanks though, Dave
P.S. I have a working class that can execute commands (.NET Process object) and do impersonation (Logon/DuplicateTokenEx) and capture output but it does not manage to actually get network credentials for the domain user being
impersonated even though I ask for them and the DuplicateTokenEx seems to work fine.

Dave
"Marshal Antony" <ma***********@yahoo.com> wrote in message
news:#n**************@TK2MSFTNGP10.phx.gbl...
Dave,
You can access network resources of another machine using
impersonation.
Follow this procedure :

* Create a windows user on the web server you are
using(your machine),call it eg: netuser1.
* In the Web.Config file of your ASP.NET application,
<system.web>
<identity impersonate="true" />
</system.web>

Then create a user with the same name netuser1 with the same password on
the machine on the network and give access
to this user for the resource you want to access.(For eg: give security permission,read,write etc. to the folder on that machine).
You can put the user name and pasword in the identity part in the
Web.config but that is not secure.
So it will be secure to put the impersonate user name and password on
the
directory security of virtual directory of iis.
For eg : in iis 5.0 in Windows 2000,

* Right click on the virtual directory
* Goto directory security tab and click on the first EDIT button
for anonymous access and authentication control.
Click on the EDIT of anonymous access,click Browse and change the user name and password to netuser1 and its password.
Now you can access the network
resource..

For eg :
You can access the file on another machine
string filename="\\\\ip addres of the
machine\\sharename$\\foldername\file1.txt;

StreamReader oSR=new StreamReader(filename);
and loop through it to get the information on that file.
Hope this helps..
Regards,
Marshal Antony
http://dotnetmarshal.com

"Dave Kolb" <Da**************@remove.sas.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
> When using Windows Authentication with ASPNET and using either <identity > user= pw=/> on web.config or programatically via

LogonUser/DuplicateTokenEx
> I do not get a token with network credentials as I can only do things on
my
> own machine. I use a combination of these calls asking for full
access and a
> primary token successfully and still get all network access
denied. I check
> that I have successfully switched identities by printing them out. Dave >
>
> "bruce barker" <no***********@safeco.com> wrote in message
> news:OG**************@TK2MSFTNGP12.phx.gbl...
> > the token you duplicate must be a primary token if you want to
use
it
for
> > network access. if you are impersonating the iis user, they must
use basic
> > authentication (which results in a primary token) or digest
which gives a
> > token that supports delegation (if delegation is turned on).
> >
> > if you have a standard domain login & password you want to use,
you can
> use
> > them to create a primary token, though you migh as well set the login
&
> > password in the web config.
> >
> >
> > -- bruce (sqlwork.com)
> >
> >
> >
> > "Dave Kolb" <Da**************@remove.sas.com> wrote in message
> > news:OS**************@tk2msftngp13.phx.gbl...
> > > Is there any other [simple] solution for an ASPNET application

to access
> > > network resources other than running as SYSTEM, using
delegation (a > > > nightmare to get to work) or the COM+ solution? I cannot seem
to > > impersonate
> > > a user and obtain network credentials using the DuplicateTokenEx call
> with
> > > appropriate parameters even though the call seems to not fail.
I check
> my
> > > identity has changed but can only still do local commands.
> > >
> > > I would consider running CreateProcessWithLogonW after impersonating
an
> > > admin if I could reliably supply stdin and capture stdout and
stderr
but
> > > can't figure out how to do this in .NET though have done

something > similar
> > > with standard I/O streams and CreateProcess in a C++ OCX

control before.
> > >
> > > Main idea is do be able to display network related command
output in
an
> > > Intranet web page and still maintain reasonable security on

the internal
> > > server.
> > >
> > > CreateProcessWithLogonW would be the ticket if I could
impersonate an
> > Admin
> > > w/o network credentials and then could capture the process'

output. > > >
> > > Thanks for any ideas or samples,
> > > Dave
> > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Joseph | last post by:
Hello We have a web application written in ASP.Net that calls an external C# program (.exe). This C# program needs to access data from a different server and is not able to do so. We use impersonate...
6
by: moonriver | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004...
8
by: Lam | last post by:
HI anyone knows how can I open a mapped network file in C#? I try string file = @"T:\file.txt"; it shows me the error: "Could not find a part of the path" but if I copy the file to my C dirve,...
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
3
by: James N | last post by:
My ASP.NET application needs read/write permissions for drive "Z:", which is mapped to my Linksys Gigadrive (Network Attached Storage...if anyone is familiar with that). If I configure the...
5
by: Brent Burkart | last post by:
What steps must I take to ensure that my application will be able to access network folders. I want to only use the ASPNET account, but I am not sure how this is done. Thanks, Brent
4
by: Kim Kragh | last post by:
Hi. I've tried to save, move files from asp.net (using the FileInfo object). It works fine locally, but I can't make it work on network drives. I have granted the aspnet user all required...
4
by: A.M-SG | last post by:
Hi, I need an aspx's code behind program access to a network folder which is only available for specific active directory user. How can I have that specific aspx code login into the active...
7
by: Ronald S. Cook | last post by:
In my .aspx page, I am trying to read file that is on a different on the company network. When I map a drive to it and call from within my .aspx page, I get this error:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.