CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.security Tags:
Item Type: NewsGroup Date Entered: 2/5/2008 5:01:38 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 122 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
garlin
Asp.Net User
Help - about invoke win32 API in ASP.Net2/5/2008 5:01:38 AM

0/0

I try to invoke a few win32 APIs in an ASP.net page. But came across some problems.

I am using C#, .net 2.0 and Visual Studio 2005 on WinXP system. The IIS version is 5.1.

In the Page_Load() function, I invoke win32 API FindWindow() to get a window's handle.
When running the page with the Visual Studio Web Server, everything goes fine. But when running it under IIS, FindWindow() fails to get the handle. The error code returned by GetLastError() is 1008. After some googling, I added AspCompat="true" to @Page. Then, the error code changed to 997, which is ERROR_IO_PENDING. I have no idea what's going on here.

I think this is related to privilege problem. So I tried to add this line to the Web.config file: <identity impersonate="true" userName="myuser" password="password" />. And System.Security.Principal.WindowsIdentity.GetCurrent().Name returns the correct username. But still got the same error. Have I missed something??

And from that I have the following question: under IIS, even provided with full access permission, for example impersonating administrator, I can not do anything I like, is that true??
Or put it in another way, as long as the codes can work in Visual Studio Web Server, they will work in IIS if given enough privileges, is that true??

Someone who knows about this please help me. Thanks a lot!!
ivanatanasov
Asp.Net User
Re: Help - about invoke win32 API in ASP.Net2/5/2008 1:31:43 PM

0/0

hi boy,

that is true, but you never have to deliver full access to web application.   



My blog is here.
garlin
Asp.Net User
Re: Help - about invoke win32 API in ASP.Net2/5/2008 1:39:21 PM

0/0

hi, ivanatanasov

You mean the first or the second??

And could you please tell me how I can solve the problem? Please help!

ivanatanasov
Asp.Net User
Re: Help - about invoke win32 API in ASP.Net2/6/2008 2:26:19 PM

0/0

can you put your exact error 



My blog is here.
garlin
Asp.Net User
Re: Help - about invoke win32 API in ASP.Net2/7/2008 4:44:41 AM

0/0

The error is that when I invoke win32 API FindWindow() through DllImport in the Page_Load() method, I get null in IIS(in Visual Studio Web Server it's ok). And the errorcode returned by GetLastError() is 1008, which is ERROR_NO_TOKEN -- "An attempt was made to reference a token that does not exist.", even I impersonate administrators group user. So I am confused and think maybe there are some differece between Visual Studio Web Server and IIS on this issue, but I don's know the details behind and can not find a way to solve it.

garlin
Asp.Net User
Re: Help - about invoke win32 API in ASP.Net2/8/2008 6:25:59 AM

0/0

After some thinking and coding, I found a workaround to this problem by DotNet remoting. I built a server on tcp channel and let the remote object to invoke the win32 api. Then in the IIS I made the webpage to call the remote method and succeeded getting the handle. The reason is obvious. The win32 api is invoked in the Appdomain different to the asp.net one and the server program runs as a local application with full privileges.

But I still wonder why in IIS it failed to get the handle with full access privileges.

6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET and ASP .NET Authors: Dhananjay Katre, Prashant Halari, Narayana Rao Surapaneni, Meghana Deshpande, Manu Gupta, Pages: 487, Published: 2003
Visual Basic 2005 Recipes: A Problem-Solution Approach Authors: Todd Herman, Allen Jones, Matthew MacDonald, Rakesh Rajan, Pages: 664, Published: 2007
Visual C# 2005 Recipes: A Problem-Solution Approach Authors: Allen Jones, Matthew MacDonald, Rakesh Rajan, Pages: 565, Published: 2006
Pro .NET 2.0 Windows Forms and Custom Controls in VB 2005 Authors: Matthew MacDonald, Pages: 1036, Published: 2006
ASP.NET: Tips, Tutorials, and Code Authors: Scott Mitchell, Stephen Walther, Doug Seven, Donny Mack, Billy Anders, Adam Nathan, Dan Wahlin, Pages: 878, Published: 2001
.NET Development Security Solutions Authors: John Paul Mueller, Mueller, Pages: 472, Published: 2003
Professional ASP.NET 1.1 Authors: Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson, Pages: 1337, Published: 2004
Designing Microsoft ASP.NET Applications Authors: Douglas J. Reilly, Pages: 402, Published: 2001
Visual Basic 2008 Recipes: A Problem-Solution Approach Authors: Todd Herman, Allen Jones, Matthew MacDonald, Rakesh Rajan, Pages: 680, Published: 2008
Pro VB 2008 and the .NET 3.5 Platform Authors: Andrew Troelsen, Pages: 1377, Published: 2008

Web:
Help - about invoke win32 API in ASP.Net - ng.asp-net-forum ... Help - about invoke win32 API in ASP.Net, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net.security, Date: 2/5/2008 5:01:38 AM, ...
A simple sample of invoking Win32 API in ASP.NET 2.0 (C#) This tutorial show you a simple example to explain how to invoke Win32 API in ASP.NET 2.0 and C#.
Working with Win32 API in .NET Jul 23, 2007 ... NET application to enjoy the luxury of Win32 API. .... Just create a simple ASP. NET page and export it to PDF with ExpertPDF HtmlToPdf ...
Calling Win32 API Calls from C# using Platform Invoke - .Net ... Sep 17, 2008 ... DevASP.NET for ASP.NET, VB.NET, XML and C# ( ... In this article I’ll try to explain how you can call Win32 API functions from within C# ...
COM Interoperability in .NET How do I open a URL in a new Browser Window in ASP.NET? ... NET TYPES CALLING C DLLs (Win32 API). Platform Invoke:. The platform invoke services offers a ...
CodeProject: Win32 API: C++ to .NET. Free source code and ... This is a conversion sheet to go from C++ API calls to .NET P/Invoke. ... Password Remember me? help Lost your password? ... ASP.NET Controls ...
411ASP.NET: Search Results This tutorial will show you a simple example to explain how to invoke Win32 API in ASP.NET 2.0 and C#. Author: AspNetTutorials.com Code: ASP.NET v2.0 & C# ...
Win32 API Help - bytes Hi All, Does any1 know which Win32 API is called when you hit the ... That is the ShutdownWindows on the Shell application (invoke through COM ...
Choosing a Windows Embedded API: Win32 vs. the .NET Compact Framework The set of Win32 APIs that are required to support .NET Compact Framework .... then use the Platform Invoke and MessageWindow support when you need the help ...
WinForms UI Thread Invokes: An In-Depth Review of Invoke ... Just Links. Weblogs @ ASP .NET .... They use GetWindowThreadProcessID, a Win32 API call, to check the handle and find it's thread and process ID (note the ...




Search This Site:










can anyone tell me the best method to at first display say gridview of list titles...

html editor for 2.1.2 that works in firefox

building don net nuke for the first time

no option to upload skin...

registration and catalook

how do i make links to documents more secure?

passwordrecovery control - forcing the security question step when requiresquestionandanswer = false

wizard page flickering and picture flashing

cgi with a variable?

calendar popup

after logged in, the cookie gets lost by visit another page. why?

overlapping labels

response.redirect and request.urlreferrer

forms authentication - really makes sense ?

multilanguage question in dnn 3.0.12

make vwd use "place code in a separate file" by default?

windows authentification with storing roles in database

which manner to use?

user.identity.name and sqldatasource

error inserting userid into database

what is webparts and viewstate and session and cookie?

bug: manageusers.aspx - remove users

why does my gridview disappear when previewed with a browser?

query builder

asp.netcalling webform with vb code behind

i cant gain access to the manage page

i used to use (fnc_commonfunctions.asp) please help!

restoring dnn

how to declare inner class in vb.net

gridview implementation

 
All Times Are GMT