用于检测IIS是否为“Windows身份验证”的ASP.NET代码已启用 [英] ASP.NET code to detect whether IIS "Windows Authentication" is enabled

查看:324
本文介绍了用于检测IIS是否为“Windows身份验证”的ASP.NET代码已启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从ASP.NET代码中检测到IIS当前是否具有Windows身份验证可用?

I would like to be able to detect, from ASP.NET code, whether IIS currently has "Windows Authentication" "available"?

从我的应用程序安装开始目前在匿名访问下运行,我想检测:

Starting from my application installed and currently running under "Anonymous Access", I want to detect:


  1. Windows身份验证组件实际上已经安装在IIS中(例如一些IIS7默认安装它不是
    );和...

  2. Windows身份验证实际上是在我的虚拟根/位置上已启用。

我希望这些信息让管理员知道他是否需要在 之前采取行动他实际上是在我的应用程序上尝试将其打开。

I want this information to let the Administrator know whether he needs to take action in IIS before he actually attempts to switch it on on my application.

(因此,例如,我认为 IIS7:如何定义Windows身份验证是否已打开?对我没有帮助,因为它正在查看它是否已经在我的应用程序中;我想知道是否它是安装/可以打开。)

(Hence, for example, I think IIS7: How to define that windows authentication is turned on? does not help me, as that is looking at whether it is already on for my application; I want to know whether it is installed/can be turned on.)

我的解决方案需要在7之前的IIS版本以及之前工作(或者至少不会失败) 7本身,所以如果有差异,我需要知道。谢谢。

My "solution" would need to work (or at least not "fail") with versions of IIS prior to 7 as well as 7 itself, so if there are differences there I need to know. Thanks.

推荐答案

在默认的aspx页面上,检查用户是否设置为WindowsPrincipal类型。如果未启用Windows身份验证,则类型将不同。

On the default aspx page check if the user is set to a type of WindowsPrincipal. If Windows authenication is not enabled then the type will be different.

此外,对于Windows身份验证工作,浏览器应配置为NTLM握手。

Also for windows authenication to work, the browser should be configured for the NTLM handshake.

将添加一些代码稍后!

这篇关于用于检测IIS是否为“Windows身份验证”的ASP.NET代码已启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆