如何在ASP.NET中使用Windows身份验证时注销,如此web.config?
<authentication mode="Windows" />
Run Code Online (Sandbox Code Playgroud)
我已经尝试过以下尝试失败了.它重定向,但不会注销用户.
void logoutButton_Click(object sender, EventArgs e) {
HttpContext.Current.Session.Clear();
HttpContext.Current.Session.Abandon();
ViewState.Clear();
FormsAuthentication.SignOut();
Response.Redirect("/");
}
Run Code Online (Sandbox Code Playgroud)
背景资料:
我必须使用Windows身份验证,因为我需要使用Active Directory模拟身份以获取对本地文件的访问权限.而且我无法模仿使用Forms身份验证,因为它HttpContext.Current.User.Identity
不会是一个WindowsIdentity
.
使用表单身份验证进行模拟
我有一个ASP.NET站点,必须使用表单身份验证而不是Windows身份验证来访问ActiveDirectoryMembershipProvider
.该站点必须使用表单,因为它们需要设计的输入表单,而不是Windows身份验证使用的浏览器身份验证弹出窗口.
该站点需要模拟通过Active Directory登录的用户访问用户特定文件.
但是,WindowsIdentity.GetCurrent()
由于是不一样的HttpContext.Current.User.Identity
,虽然我的web.config包括:
<authentication mode="Forms">
<forms loginUrl="login.aspx" timeout="480"/>
</authentication>
<identity impersonate="true" />
Run Code Online (Sandbox Code Playgroud)
我无法使用LoginUser()
,WindowsIdentity.Impersonate()
因为我需要冒充AD用户来获取他们的特定权限,而我不知道用户的密码,因为Forms负责登录.
是否可以从login.aspx.cs获取System.Web.UI.WebControls.Login.Password
,然后将LoginUser()
令牌保存在会话变量中以供WindowsIdentity.Impersonate()
日后使用?或者可能采用更安全的方法冒充正确的方法?
我很困惑为什么表单身份验证不能自动 <identity impersonate="true" />
我已阅读此http://msdn.microsoft.com/en-us/library/ms998351.aspx但它使用Windows身份验证.
asp.net impersonation forms-authentication active-directory windows-authentication
我无法找到一种干净的方法来实现适用于任何类型的算法.
以下代码会在尝试将字符串或类型化切片转换为接口时产生错误,并且您无法比较接口{}对象: invalid operation: result[0] > result[n - 1] (operator > not defined on interface)
func main() {
c := Algo("abc")
//...
c := Algo([3]int{1,2,3})
//...
}
func Algo(list []interface{}) chan []interface{} {
n := len(list)
out := make(chan []interface{})
go func () {
for i := 0; i < n; i++ {
result := make([]interface{}, n)
copy(result, list)
// an actually useful algorithm goes here:
if (result[0] > result[n-1]) {
result[0], result[n-1] = result[n-1], result[0]
}
out <- result …
Run Code Online (Sandbox Code Playgroud) 我~/.vimrc
使用以下状态行设置
set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ [0x\%02.2B]\ %l/%L,%v\ %p%%
Run Code Online (Sandbox Code Playgroud)
一切都保持一致.help 'statusline'
说该-
字符用于"左对齐项目.当minwid大于项目的长度时,默认是正确的."
但是,我无法使用(或不使用)-
将事物对齐.
让一组物品左对齐而一组右对齐的例子是什么?
我也试过用=
它,但它只打印=
标志.
如果我将.NET DirectoryEntry.Path设置为:
LDAP://CN=John Smith,OU=Group Name,DC=example,DC=com
Run Code Online (Sandbox Code Playgroud)
一切都很好,我得到了我需要的DirectoryEntry.但是,我不知道用户的真实通用名称(CN).我只知道他们的用户名"John.Smith".
那么,我该如何查询用户名?我没有成功地尝试了以下所有方法:
LDAP://CN=John.Smith,OU=Group Name,DC=example,DC=com
LDAP://sAMAccountName=John.Smith,OU=Group Name,DC=example,DC=com
LDAP://userPrincipalName=John.Smith,OU=Group Name,DC=example,DC=com
LDAP://userPrincipalName=John.Smith@example.com,OU=Group Name,DC=example,DC=com
LDAP://uid=John.Smith,OU=Group Name,DC=example,DC=com
LDAP://o=John.Smith,OU=Group Name,DC=example,DC=com
Run Code Online (Sandbox Code Playgroud) 有时在浮动的div.IE6不显示标签,但它确实正确地分隔图像,当您右键单击图像时,它会提供正确的大小和文件大小等细节.它只是不显示图像:
<div style="float:left">
<img src="one.gif" />
</div>
<div style="float:left">
<img src="two.gif" />
</div>
Run Code Online (Sandbox Code Playgroud)
这些图像不会显示在IE6中,而是显示在Firefox/Safari/etc中......解决方法是什么?