如何在Windows身份验证后获取用户信息? [英] How can I get user information after windows authentication?

查看:143
本文介绍了如何在Windows身份验证后获取用户信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我建立一个小型的Asp.net网站并使用Windows身份验证。现在我想在Windows身份验证后获取用户信息并将其转换为另一个网站中的新用户对象并将其保存到cookie或只是将用户信息保存到数据库。然后另一个Web应用程序可以访问这些信息。



谁可以给我一些建议?



谢谢。

Hi,all!

I build a small Asp.net website and use windows authentication. Now I want to get user information after windows authentication and convert it to a new user object in another website and save it to cookie or just save the user information to database. Then another web application can access such information.

Who can give me some suggestion?

Thanks.

推荐答案

Christian Graus,谢谢你的重播。我想我应该更详细地描述一下我的问题。

我正在建立一个小型的Asp.net MVC网站,我试图让它足够灵活以满足用户的要求。你知道,有些用户使用域,有些用户没有使用域。所以我的Web应用程序应该支持表单autherization和windows autherization,然后用户可以选择如何使用我的系统。

我设置我的应用程序使用表单autherization,因为我真的需要在我的系统中的用户列表。对于使用域的用户,我会自动且频繁地将所有域帐户复制到我的系统。我建立了另一个网站,仅用于Windows autherization。在这个网站上,我想获得用户域帐户并将其转换为我系统中的用户。

到目前为止,我可以在Windows autherization之后从HttpContext.Current获取用户名,但是当请求从windows autherization重定向到真正的Web应用程序站点,我无法在HttpContext.Current中看到用户信息。我已将这两个网站放在同一个域中。我知道同一个域中的两个网站可以共享相同的表单autherization cookie,但我不确定他们是否可以共享autherization cookie,即使他们使用不同的autherization方法。这就是我发布问题的原因。
如果同一域中的两个网站但使用不同的autherization方法无法共享cookie信息,我想我能做的就是在windows autherization site收集用户信息将其保存在数据库中,并重定向到另一个网站。在下一个网站中,我可以阅读第一个网站创建的记录。然后我可以获取用户信息,用户可以使用windows autherization。

我仍​​然不想这样做,即使看起来可行。我认为在两个网站上共享cookie更加官方。



所以我真正的问题是:

1,牵引同一域名的网站但是使用不同的autherization mothod可以共享用户信息吗?

2,如果可以的话,我该怎么办?



谢谢
Hi, Christian Graus, thanks for your replay. I think I should describe my question more detail.
I''m builing a small Asp.net MVC website, and I try to make it flexible enough to fit user''s requirement. You know, some user use domain and some one did not use it. So my web application should support form autherization and windows autherization, then user can select how to use my system.
I set my application to use form autherization, because I realy need a user list in my system. For the user who use domain, I will copy all the domain account to my system automatically and frequently. I build another website just for windows autherization. In this website, I want to get the user domain account and convert it to the user in my system.
So far, I can get the user name from HttpContext.Current after windows autherization, but when the request redirect from windows autherization to the real web application site, I can not see the user information in HttpContext.Current. I have putted the two websites in same domain. I know two web sites in same domain can share same form autherization cookies, but I''m not sure can they share the autherization cookies even they use different autherization method. This why I post my question.
If the tow web sites in same domain but use different autherization method can not share cookies information, I think what I can do is gather the user information in windows autherization site and save it in database, and redirect to the another web site. In the next web site, I can read the record the first site create. Then I can get the user information and user can use windows autherization.
I still won''t to do like this way, even though it seem feasible. I think share cookie in the two web site is more offical.

So My real question is:
1、Tow websites in same domain but use different autherization mothod can share the user information or not?
2、If it can, how can I do it?

Thanks


您可以使用cookie来存储站点之间可用的信息。你提到过cookies,所以你似乎知道这一点。你还想要什么其他信息?在DB中存储信息无济于事,您仍然需要用户登录这两个站点才能知道他们的数据是什么
You can use cookies to store information that is available between sites. You mentioned cookies, so you seem to know that. What other info do you want ? Storing info in the DB won''t help, you still need users to log in to both sites to know what data is theirs


这篇关于如何在Windows身份验证后获取用户信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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