如何从窗口活动目录获取用户名密码 [英] how to get username password from window active directory

查看:118
本文介绍了如何从窗口活动目录获取用户名密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何根据Windows身份获取用户名和密码。如果用户根据活动目录有效,则没有登录屏幕,否则他可以访问网站。我们怎么设置这个?有人可以帮我从哪里开始?

Hi all ,
i want to know how to get user name and password based on windows identity. there will be no login screen if user is valid based on active directory he can access website otherwise not. how can we set this? can some one please help me where to start ?

推荐答案

内部加密的AD密码,除了密码剩余的所有用户信息,你可以使用PrincipalContext类获得可以在System.DirectoryServices中使用。



AD password encrypted internally so except password rest of all user info you can get by using "PrincipalContext " class that will be available in System.DirectoryServices.

// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// find user by name
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "John Doe");

// if we found user - inspect its details
if(user != null)
{
    string firstName = user.GivenName;
    string lastName = user.Surname;
    string email = user.EmailAddress;
    string phone = user.VoiceTelephoneNumber;
}


这篇关于如何从窗口活动目录获取用户名密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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