473,394 Members | 1,866 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.

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.LogonUserIdentity AuthenticationType for this but
when I traced with this code
if (Request.LogonUserIdentity != null)
{
sb.AppendFormat("Request.LogonUserIdentity AuthenticationType: {0}<br />",
Request.LogonUserIdentity.AuthenticationType);
.....

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

Should I read web.config ?

Thanks for help

CS

May 28 '07 #1
2 2423
Use Request.IsAuthenticated and then, Request.AuthenticationType
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.LogonUserIdentity AuthenticationType for this but
when I traced with this code
if (Request.LogonUserIdentity != null)
{
sb.AppendFormat("Request.LogonUserIdentity AuthenticationType: {0}<br />",
Request.LogonUserIdentity.AuthenticationType);
.....

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.IsAuthenticated or Request.AuthenticationType, they're
just the same like the
HttpContext.Current.User.Identity.AuthenticationTy pe(IsAuthenticated ).
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 <authentication 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 <authentication modesetting from application's web.config
file. You can use the WebConfigurationManager 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.Identity's type, for windows
authentication, it is of "WindowsIdentity" type while for
FormsAuthentication, 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
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....
3
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...
1
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...
3
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"...
5
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
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...
1
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...
3
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...
1
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...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.