当前位置:编程学习 > JAVA >>

用java如何获取AD域的用户和组的信息,

用java获取AD域中的用户以及组的所有信息 --------------------编程问答-------------------- 自己先顶一下!!!!!!!!!!! --------------------编程问答-------------------- --------------------编程问答-------------------- 哎,可怜啊,这个难搞哦,给你一段参考(不过这是C#的):

myLDAPPath = "LDAP://你的域名";

DirectoryEntry mySearchRoot = new DirectoryEntry(myLDAPPath);
DirectorySearcher myDirectorySearcher = new DirectorySearcher(mySearchRoot);

#region all informations

myDirectorySearcher.Filter = ("(objectClass=user)"); //user表示用户,group表示组
foreach (SearchResult mySearchResult in myDirectorySearcher.FindAll())
{
if (mySearchResult != null)
{
// Get the properties of the 'mySearchResult'.
ResultPropertyCollection myResultPropColl;
myResultPropColl = mySearchResult.Properties;
Console.WriteLine("The properties of the 'mySearchResult' are :");

foreach (string myKey in myResultPropColl.PropertyNames)
{
string tab = "    ";
Console.WriteLine(myKey + " = ");
foreach (Object myCollection in myResultPropColl[myKey])
{
Console.WriteLine(tab + myCollection);
}
}
mySearchRoot.Dispose();
}
}
--------------------编程问答-------------------- 这个简单啊!! --------------------编程问答--------------------
引用 3 楼 xiaonix111 的回复:
哎,可怜啊,这个难搞哦,给你一段参考(不过这是C#的):


C# code



123456789101112131415161718192021222324252627282930

myLDAPPath = "LDAP://你的域名";                   DirectoryEntry mySearchRoot = new DirectoryEntry(m……

这代码 一开始变量是string是都没写 我还解析呢 才看到字符串 加了个string --------------------编程问答-------------------- 难搞,又不稳定
我的解决方法是用.net输出webservice,然后java访问webservice
.net读取ad输出webservice 就简单又稳定 --------------------编程问答-------------------- 用得上的好东西啊,收藏了先
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,