用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();
}
}
这代码 一开始变量是string是都没写 我还解析呢 才看到字符串 加了个string --------------------编程问答-------------------- 难搞,又不稳定
我的解决方法是用.net输出webservice,然后java访问webservice
.net读取ad输出webservice 就简单又稳定 --------------------编程问答-------------------- 用得上的好东西啊,收藏了先
补充:Java , Java EE