473,387 Members | 1,510 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,387 software developers and data experts.

Windows identity during asynchronous calls

I'm trying to access a SQL server from a thread started from an asp.net
application and get a "Cannot log into database as user null..." error. How
can I make the thread inherit the same identity as the calling process?
When I spin off the thread I have seen that it typically runs as NT
ANONYMOUS\SYSTEM (via
System.Security.Principal.WindowsIdentity.GetCurre nt().Name). I have had
intermittent success
passing the token of the calling process and impersonating it in the called
process but once in a while hit an exception when trying to impersonate.

Web Config of calling process:
<authentication mode="Forms" >
<forms name="adAuthCookie" loginUrl="_mem_bin/formslogin.aspx"
protection="All" path="/" timeout="60" ></forms>
</authentication>
<identity impersonate="true" />

Web Site Directory Security of calling process is set to Anonymous Access.
Account used for anonymous access is a user w/ permissions to our SQL Server
db. Windows Integrated Authentication is also checked.

calling asynchronous process:
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf lfd.SubmitRequest),
System.Security.Principal.WindowsIdentity.GetCurre nt().Token)

Impersonation Logic:
Sub SubmitRequest(ByVal Token As Object)
System.Security.Principal.WindowsIdentity.Imperson ate(CType(Token,
System.IntPtr))

Thanks,

Dave


Nov 17 '05 #1
1 1693
Hi Dave,

Thanks for posting in the group.

Because forms users usually are not Microsoft Windows users, they do not
have any roles associated with them by default. Thus, you must attach the
roles of the authenticating user to that user's identity so that you can
implement the role-based security inside your code.

Generally speaking, we can achieve it in Application_AuthenticateRequest
event handler in global.asax. For detailed sample codes, please refer to KB
article:
HOW TO: Implement Role-Based Security with Forms-Based Authentication in
Your ASP.NET Application by Using Visual C# .NET
http://support.microsoft.com/?id=311495

Another article is also useful in this area.
HOW TO: Authenticate Against the Active Directory by Using Forms
Authentication and Visual C# .NET
http://support.microsoft.com/?id=316748

Hope this help.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
Nov 17 '05 #2

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
2
by: Dion Heskett | last post by:
Hi I get a InvalidOperationException message when I click button2 at this line of code textBox1.Text = whoIs1.EndLookup( asyncResult ); Should I now be implementing the BackgroundWorker Class...
0
by: Dave Mullen | last post by:
I'm trying to access a SQL server from a thread started from an asp.net application and get a "Cannot log into database as user null..." error. How can I make the thread inherit the same identity...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
4
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I copied my portal to WIndows 2003 and now I am getting: Server Error in '/portal' Application. -------------------------------------------------------------------------------- The current...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
1
by: jalupinu | last post by:
My OS is Winxp SP2 and the software I am having trouble with is Maximizer 9.5 Enterprise. It has a Web Portal feature that i am trying to use and followed the instructions to set it up however I keep...
2
by: =?Utf-8?B?d2R1ZGVr?= | last post by:
I have a website using windows integrated security, with anonymous access turned off. The site is used to query orders from a database and when the search takes a long time, a windows login box...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.