Windows Principle security working in C#.NET Windows application, but not on ASP.NET Web Application with C#.NET as code behind


AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

WindowsPrincipal usrPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;

WindowsIdentity usrIdentity = (WindowsIdentity)usrPrincipal.Identity;

String usrPrincipalName = usrPrincipal.Identity.Name;

String usrPrincipalType = usrPrincipal.Identity.AuthenticationType;

String usrPrincipalAuth = usrPrincipal.Identity.IsAuthenticated.ToString()

 

Can you check why this code is not working in Web application, however it is working in Windows application

0
vg1985
1/11/2008 4:22:59 PM
asp.net.security 27051 articles. 1 followers. Follow

16 Replies
2645 Views

Similar Articles

[PageSpeed] 20

 Is it crashing at runtime? Not compiling? What is the error message?


--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/11/2008 4:50:42 PM

Actually i am not getting any error message, however.., in Windows Application, it is returing my Domain Login.., which it is not in case of Web Application

0
vg1985
1/11/2008 4:59:41 PM
You have to activate Windows Integrated Security in IIS for this site for the Principal to be populated. Have you done that?

--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/11/2008 5:13:34 PM

i am not sure about that.., can you please let me know, where to check..

0
vg1985
1/11/2008 5:19:19 PM
This will only work over an intranet, or if you create Windows user accounts for each person accessing your application. http://www.eggheadcafe.com/articles/20050703.asp

--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/11/2008 5:54:47 PM

Thanks. i checked the article.., but still it is not working.

Please check the following link for the screeshot of IIS Security settings for the site. 

 

0
vg1985
1/12/2008 8:00:52 AM

You have to uncheck "anonymous access.". Then if you are not on an intranet, it will prompt you for a login when you open the site and you have to login with a valid windows account for this machine (or domain). Once you've done that your WindowsPrincipal will be populated.


--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/13/2008 3:11:21 AM

i tried this one too, but still it is ot working in intranet. Also i am facing one more issue, there is one more project, i am able to open the site on my local system, by http://ipaddr/app/p1.aspx however the same is not working on the systems connected to same intranet.

 

0
vg1985
1/13/2008 8:49:13 AM

sorry.., i changed wrong site., my first problem is resolved.., thanks a lot.., but my second problem is still there.., hope you give resolution for that too.. Big Smile

0
vg1985
1/13/2008 8:57:11 AM
You'll need to provide more information, like the exact error message, a screen shot...something of that nature. "Not working" isn't enough information.

--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/13/2008 3:18:45 PM

it is showing page cannot be displayed in other systems, however the same is working on my system with IP.

 

 

0
vg1985
1/13/2008 3:43:19 PM
If you are running it through you Visual Studio development web server then it can't be viewed from another machine. You can only view it locally. To view from another machine you have to use IIS.

--
Rob Walling
ASP.NET MVP
My blog, Software by Rob

Please click "Mark as Answer" if my post helped you.
0
walling
1/13/2008 4:03:18 PM

IIS is installed on my system.., i can view by using http://ipaddr/site.aspx , by directly typing the address into the explorer.., however.., it is not working on other machines..

0
vg1985
1/13/2008 4:57:08 PM

Hi

Have you turn on the NetBIOS support in windows? Try to diagnose and test TCP/IP or NetBIOS Network connections like this article

http://support.microsoft.com/kb/300986/en-us


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/15/2008 3:36:27 AM

i tried connections too from the link, and everything seems fine... i think there is some problem in IIS which i am not able to get...

0
vg1985
1/15/2008 8:58:05 AM
Reply:

Similar Artilces:

Converting windows application using web service from Visual C#.net 2003 to Visual Studio.net 2005
Hello, everyone! I have a solution which contains a windows project,a web service project and several other library projects. These projects were coded under visual c#.net 2003. Now I need to converted them to use Visual Studo.net 2005. Does any one know any article providing step-by-step guide  to converting WINDOWS APPLICATION with web service? I can find one under MSDN for converting web project.  But I guess I am a little confused if mine should follow this article since I am using web service in my windows application? Thanks a lot in advance.  ...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Can a .NET web based intranet application call a windows based .NET application?
   Is it possibly to have an asp.net 2.0 application call/invoke a windows desktop application written in .NET 2.0? We have a .NET 1.0 windows desktop application that was written in C#. We also have a new .NET intranet web application written in asp.net 2.0. Is it possibly to have a button on the web application that when pressed will invoke the .NET 1.0 windows application? And then if someone closes the application, it will return control back to the ASP.NET 2.0 application?    Are you referring to running a WinForms application on the server or on the client PC? ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Integrating the C#.net and VB.net application
Hello All,  I'm trying to integrate the C#.net application and VB.net application.  Can you give me any suggestions of how to merge them.  Thanks in Advance You are probably goign to have to convert one of the applications to the other language at one point.  There are online conversion tools to help http://www.carlosag.net/Tools/CodeTranslator/- WilliamPlease mark the most helpful reply/replies as "Answer".Give some of my PWSK modules a try.  Type of application?We All move to our original place.Don't forget.Imran Baloch @weighfield: I d...

Convert VB.Net application to C#.net
Haican any one help me to convert VB.Net application in this link to C#.net http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6718&lngWId=10RegardsAnu Palavila  Regards Anu Palavila Use this Free Conversion tool - http://www.developerfusion.com/tools/convert/vb-to-csharp/  ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips Other Code Convertors (convert VB to C# and C# to VB) http://converter.telerik.com/ http://www.developerfusion.com/tools/convert/csharp-to-vb/ http://www.dotnetspider.com...

C#.NET in VS.NET vs. C# in Web Matrix
Hi all, I am very new to .NET ... I realized C#.NET is only available from Visual Studio.NET ... however, I realized Web Matrix also allowed us to choose C# as language but not C#.NET ... they are not the same, right? If not, then why it's in Web Matrix which runs ASP.NET?? If I need to run C#.Net, I MUST GET VS.NET, right? Can C#.NET has the abality to create chat program? Thank you very much. C#.NET and C# are the same thing. JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Learns New TricksPreferred programming language: cuneiform on clay tablets So ... that means I can use web matrix t...

how to convert .Net CF application to .Net framework on windows
hi all,    I want to convert .NET Compact Frameworkd application to .NET framework application on windows. Can anybody help me how to do this. thanks Hi, Hope this helps, please read through it all and it will give you the answer. http://msdn.microsoft.com/en-us/netframework/bb495180.aspxPlease remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. Check out http://www.dgwebit.co.uk...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Using .net AJAX enabled application in non .net Web Application
Hi,Does anyone have similar experience in development?  I want to check if it's possible to run .net ajax object (from one standalone .net framework platform in company) with non .net application (i.e. J2EE web application)?  It is because we want to add certain feature (i.e. office communicator chat) to our exist application (oracle J2ee). Please give me some advice :) Thanks! Hi, .Net AJAX is based on .Net Framework architecture. Thus .Net Framework currently lacks support for other platforms, such as Java. Please check this link: http://www.csharphelp.com/arch...

How to Add Applications to ADAM using vb.net or C#.net
 Hi Pls thrown light  any one on How to Add Applications to ADAM using vb.net or C#.net RegardsMallikarjunaP.Mallikarjuna...

C++.net Webservice and Window application
Hello everybody,This is my first Thread on this wonderful forum.I'm developing a webservice to create a standard communication tunnel between a Direct3D engine and an old VB6 application. The idea is to expose different methods of the Engine using a WebService. The VB6 application will control the engine with the webservice methods.I can use the unmanaged dll used by the engine in the webservice (wasn't easy). The problem, I can't create window or use existing windows. When I create a direct3D device the HRESULT gives me the "Invalid call" error. If I try to use GDI+ to...

Smart Device Application for file transfer to a remote server in .Net Compact Framework (Using Visual Studio.Net 2003,C# code)
Dear all, We are developing a smart device application (using C# code) for .Net Compact Framework where we need to write a programme in C# code to transfer a file from mobile device to remote server/machine.Can anyony help us regarding this aaplication.If you have already done this or you find any article/link regarding to this application then please let me know about that. My mail id : anirbandas.ju@gmail.com Looking forward for your reply soon. Regards Anirban   hi hav u got any solution , becoz i too need. plz share with me...

Translate c#.net code to vb.net code
Hi I can usually do the translation myself, but this time I am a bit stumped  Let us consider to rewrite Urls (more than 16000 links) using a table. Save original url and rewritten url in a table. Now add a class file in App_Code folder. class UrlRewriteModule : IHttpModule{    public void Dispose()    {        // Nothing to dispose    }    public void Init(HttpApplication context)    {        context.BeginRequest += new EventHandler(context...

Web resources about - Windows Principle security working in C#.NET Windows application, but not on ASP.NET Web Application with C#.NET as code behind - asp.net.security

Application - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Welfare experiment may have applications in Australia
A trial in Finland providing an obligation-free basic income could change how we think about welfare.

Patent application shows Apple Watch band that transforms into a case, stand and Mac accessory
An Apple patent application published today reveals an idea for an interesting variation on the magnetically-closed Milanese Loop band that allows ...

Seagate Introduces First 8 TB Hard Disk Drive for Consumer NAS Applications
Seagate Technology on Tuesday introduced its new breed of hard disk drives (HDDs) for network area storage (NAS) and RAID applications. The new ...

MBA: Mortgage Applications Increased in Latest Weekly Survey, Purchase Applications up 19% YoY
From the MBA: Mortgage Applications Increase in Latest MBA Weekly Survey Mortgage applications increased 21.3 percent from one week earlier, ...

Mortgage applications sink after rush
A Fed rate hike pulled mortgage demand forward, and made for a steep drop-off in the past two weeks.

SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika
SURPRISE! Mizzou Sees Application Drop After Days Of Protests, Illusory Klan Hoods, Poop Swastika

In Application To Move To Los Angeles, Rams Shit All Over City Of St. Louis
... to relocate to the greater Los Angeles metropolitan area. The relocation would be effective for the 2016 NFL League Year.” The Rams’ full application ...

Seagate pushing non-PC storage for 2016 with focus on surveillance applications
... products for cloud computing, consumer electronics, surveillance and enterprise storage for 2016. Seagate expects surveillance-related applications ...

Application Security Lacking in Health, Finance Apps
The survey also revealed 82 percent of app users said they would change providers if a similar provider offered a more secure mobile app.

Resources last updated: 1/15/2016 5:42:05 PM