473,594 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto know if we are in Forms or Windows authentication mode ?

WT
Hello,

I tryed to fix a variable with the current authentication mode,
I tryed to use Request.LogonUs erIdentity AuthenticationT ype for this but
when I traced with this code
if (Request.LogonU serIdentity != null)
{
sb.AppendFormat ("Request.Logon UserIdentity AuthenticationT ype: {0}<br />",
Request.LogonUs erIdentity.Auth enticationType) ;
.....

I get nothing in my stringbuilder ???
Is it normal ?

Should I read web.config ?

Thanks for help

CS

May 28 '07 #1
2 2434
Use Request.IsAuthe nticated and then, Request.Authent icationType
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"WT" wrote:
Hello,

I tryed to fix a variable with the current authentication mode,
I tryed to use Request.LogonUs erIdentity AuthenticationT ype for this but
when I traced with this code
if (Request.LogonU serIdentity != null)
{
sb.AppendFormat ("Request.Logon UserIdentity AuthenticationT ype: {0}<br />",
Request.LogonUs erIdentity.Auth enticationType) ;
.....

I get nothing in my stringbuilder ???
Is it normal ?

Should I read web.config ?

Thanks for help

CS

May 28 '07 #2
Hi WT,

As for the Requeste.IsAuth enticated or Request.Authent icationType, they're
just the same like the
HttpContext.Cur rent.User.Ident ity.Authenticat ionType(IsAuthe nticated ).
They actually represent the authentication type performed by the IIS web
server, such as "NTML" or "Negotiate" ..... rather than the authenticatio
setting of ASP.NET <authenticati on mode/>.

for your scenario, if you want to check the ASP.NET application's current
authentication mode, you can consider the following means:

1. Load the <authenticati on modesetting from application's web.config
file. You can use the WebConfiguratio nManager class to load applicationo
configuration settings. Also, for performance consideration, you can load
this setting into a class static property at application's startup time(or
at the first time the property is requested) so as to avoid multiple
accessing to the web.config file.

2. You can check the Context.User.Id entity's type, for windows
authentication, it is of "WindowsIdentit y" type while for
FormsAuthentica tion, it could be a FormsIdentity or GenericIdentity type.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.


May 29 '07 #3

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

Similar topics

2
1714
by: Senthil | last post by:
1. Created a new C# web application project 2. Change the name of webform1 to login.aspx 3. And in the .cs file change the name of the class to login, and include System.web.security namespace. 4. Place a textbox and a button in the login.aspx form. 5. Have the following code in the button click event. if (true) { FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false)
3
4851
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this error: Server Error in '/TestProjects/FormsAuthenticationTestingArea' Application.
1
2085
by: Martin | last post by:
Hi, After I gave up on tracking user sessions through the session object (Session_OnEnd is still not triggered by Abandon() even with mode=InProc and me manipulating session variables; in a new test project it is only triggered the first time, it really sucks pretty bad) I started looking at alternatives and I found FormsAuthentication. I just implemened it and it seems very nice. But, of course, there is a problem with it (it wouldn't...
3
1923
by: Sharat Koya | last post by:
Please can you help with a problem I am having. My web config is set to... <authorization><deny users="?"/> <authentication mode="Forms"> <forms name=".COOKIE" loginUrl="login.aspx" protection="All" timeout="5" path="/"/> </authentication> <identity impersonate="true"/>
5
1655
by: V. Jenks | last post by:
Using forms authentication, can I control which pages and/or directories a user would have access to or is that only available with Windows authentication? Thanks!
0
3225
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
1
1771
by: RedStain | last post by:
CONTENTS summary setup error messages compensation attempts comment SUMMARY I have an IIS6.0 server which has recently been upgraded to ASP 2.0 as a result of some of the patch requirements of some products I have installed
3
2509
by: Dan Sikorsky | last post by:
How do you get a reference to the LoginStatus control contained in the LoginView control that resides on web.master? I need to determine if the LoginStatus will show a LogOut link(for a logged in user), or show nothing at all (in the case of the user not logged in); Are there any other Membership properties that I can call that tell if the user has already authenticated.? --
1
1645
by: Chris | last post by:
Hi, we run a webapplication where users must log in. So the web.config contains: <authentication mode="Forms"/and IIS is set to Anonymous authentification. Now we want the same application to run inside our intranet. In this case, windows authentification must be used, avoiding to have to log a second time. Is it possible to put together in web.config both
0
8246
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8231
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5404
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.