Active Directory登录 [英] Active Directory login
本文介绍了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
我们需要更具体的信息来帮助您解决问题.是的,登录名应该接受密码的大写和小写,如果您使用哈希算法,那么我不明白您为什么要问这个.
我建议您在这里 [ [
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登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文