Active Directory登录

编程入门 行业动态 更新时间:2024-10-17 21:28:03
本文介绍了Active Directory登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想更改网站的登录过程-更改是合并Active Directory登录-我该怎么做? 并且登录时的用户名和密码应接受大写和小写??? 谢谢

I would like to change a login process for a website - the change is to incorporate Active Directory login - How do I go about doing this ?? and should username and password at login accept uppercase and lowercase ??? Thanks

推荐答案

您去了: 单个用户对活动目录的验证 Hi, Here you go: Validation for a single user to the active directory public static bool User() { bool validation; try { LdapConnection lcon = new LdapConnection(new LdapDirectoryIdentifier((string)null, false, false)); NetworkCredential nc = new NetworkCredential(Environment.UserName, "kals123", Environment.UserDomainName); lcon.Credential = nc; lcon.AuthType = AuthType.Negotiate; lcon.Bind(nc); // user has authenticated at this point, as the credentials were used to login to the dc. validation = true; } catch (LdapException) { validation = false; } return validation; }

列出当前域中的所有用户

Lists all the users from current domain

public static void getUser() { DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Environment.UserDomainName); string userNames = ""; string authenticationType=""; foreach (DirectoryEntry child in directoryEntry.Children) { if (child.SchemaClassName == "User") { userNames += child.Name + Environment.NewLine; //Iterates and binds all user using a newline authenticationType += child.Username + Environment.NewLine; } } Console.WriteLine("************************Users************************"); Console.WriteLine(userNames); Console.WriteLine("*****************Authentication Type*****************"); //Console.WriteLine(authenticationType); }

通过组获取用户名

Getting user names with groups

public static void fnGetListOfUsers() { // set up domain context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); // find the group in question GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "USERS"); // if found.... if (group != null) { // iterate over members foreach (Principal p in group.GetMembers()) { Console.WriteLine("{0}: {1}", p.StructuralObjectClass, p.DisplayName); // do whatever you need to do to those members } } }

从用户的活动目录中获取特定用户的详细信息

Getting a particular user details from user''s active directory

public static void fnImp() { using (var context = new PrincipalContext(ContextType.Domain, Environment.UserDomainName)) { using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) { foreach (var result in searcher.FindAll()) { DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry; if ((string)de.Properties["givenName"].Value == Environment.UserName) { //Console.WriteLine("First Name: " + de.Properties["givenName"].Value); //Console.WriteLine("Last Name : " + de.Properties["sn"].Value); //Console.WriteLine("SAM account name : " + de.Properties["samAccountName"].Value); //Console.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value); Console.WriteLine(); PropertyCollection pc = de.Properties; foreach (PropertyValueCollection col in pc) { Console.WriteLine(col.PropertyName + " : " + col.Value); Console.WriteLine(); } } } } } Console.ReadLine(); }

您需要的就是这里. --Amit

What you need is all here. --Amit

我们需要更具体的信息来帮助您解决问题.是的,登录名应该接受密码的大写和小写,如果您使用哈希算法,那么我不明白您为什么要问这个. 我建议您在这里 [ ^ ]和此处 [ ^ ] 作为一般提示,人们喜欢在这里帮助您解决编码问题,而不是一步一步地教您如何操作.他们会问您Google解决方案,如果简单的话,他们会嘲笑您是否提出了一个愚蠢的问题.我从经验中学到,Google是您解答简单问题的最好朋友. We would need more specific information to help you with your problem. And yes the login SHOULD accept uppercase and lowercase for the password, if your using a hash algorithm then I don''t see why your asking about that. I suggest you take a look here [^] and here [^] As a general tip, people like to help you with your coding problems here, not give you a step by step how to. They will ask you to Google your solution, if it is simple they will ridicule you if for ask a stupid question. I learned from experience, Google is your best friend for simple questions.

更多推荐

Active Directory登录

本文发布于:2023-11-15 05:38:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591623.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Active   Directory

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!