All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.DomainSearcher Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common;

//using Alachisoft.NCache.Management;


public class DomainSearcher {
//	private static String _domainName;
//	private static java.util.Hashtable domains;
//
//	static {
//
//	}
//
//	public static DomainInfo GetDomainInfo(String domainController, String userName, String password) {
//		DomainInfo domainInfo = new DomainInfo();
//		if (domains != null && domains.contains(domainController)) {
//			domainInfo.setDomainName(_domainName);
//			domainInfo.setUsers((java.util.ArrayList)domains.get(domainController));
//			return domainInfo;
//		}
//
//		if (domains == null) {
//			domains = new java.util.Hashtable();
//		}
//		java.util.ArrayList users = new java.util.ArrayList();
//
//		DirectoryEntry adRoot = new DirectoryEntry("LDAP://" + domainController, userName, password);
//		DirectorySearcher searcher = new DirectorySearcher(adRoot);
//		searcher.SearchScope = SearchScope.Subtree;
//		searcher.ReferralChasing = ReferralChasingOption.All;
//		searcher.Filter = "(&(objectClass=user)(objectCategory=person))";
//		searcher.PropertiesToLoad.Add("SAMAccountname");
//
//		try {
//			SearchResultCollection result = searcher.FindAll();
//			//_domainName = ExtractDomainName(result[0].Path);
//			for (SearchResult a : result) {
//				DirectoryEntry entry = a.GetDirectoryEntry();
//				String UserName = a.Properties["SAMAccountname"][0].toString();
//				//string tempName = entry.Name;
//				//string UserName = tempName.Substring(3);
//				users.add(UserName);
//			}
//		} catch (RuntimeException ex) {
//			/**[Ata] As per Raheel's suggestion.
//			*/
//			//throw ex;
//		} finally {
//			adRoot.dispose();
//			searcher.dispose();
//		}
//		//domainInfo.DomainName = _domainName;
//		domainInfo.setUsers(users);
//
//		domains.put(domainController, users);
//		return domainInfo;
//	}
//
//	public static String GetDomainName(String domainController, String userName, String password) {
//		DirectoryEntry adRoot = new DirectoryEntry("LDAP://" + domainController, userName, password);
//		DirectorySearcher searcher = new DirectorySearcher(adRoot);
//		try {
//			SearchResult result = searcher.FindOne();
//			_domainName = ExtractDomainName(result.Path);
//		} catch (RuntimeException ex) {
//			throw ex;
//		} finally {
//			adRoot.dispose();
//			searcher.dispose();
//		}
//		return _domainName;
//	}
//
//	private static String ExtractDomainName(String path) {
//		String domainName = "";
//		String[] dcPath = path.split("[,]", -1);
//		for (String str : dcPath) {
//			int index = str.indexOf('=');
//			domainName += str.substring(index + 1);
//			domainName += ".";
//		}
//		domainName = domainName.substring(0, domainName.length() - 1);
//		return domainName;
//	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy