use of com.novell.ldapchai.provider.DirectoryVendor in project ldapchai by ldapchai.
the class ChaiErrors method getErrorForMessage.
public static ChaiError getErrorForMessage(final String message) {
for (final DirectoryVendor vendor : DirectoryVendor.values()) {
final ErrorMap errorMap = vendor.getVendorFactory().getErrorMap();
final ChaiError errorCode = errorMap.errorForMessage(message);
if (errorCode != null && errorCode != ChaiError.UNKNOWN) {
return errorCode;
}
}
return ChaiError.UNKNOWN;
}
use of com.novell.ldapchai.provider.DirectoryVendor in project ldapchai by ldapchai.
the class ChaiUtility method determineDirectoryVendor.
/**
* Determines the vendor of a the ldap directory by reading RootDSE attributes.
*
* @param rootDSE A valid entry
* @return the proper directory vendor, or {@link DirectoryVendor#GENERIC} if the vendor can not be determined.
* @throws ChaiUnavailableException If the directory is unreachable
* @throws ChaiOperationException If there is an error reading values from the Root DSE entry
*/
public static DirectoryVendor determineDirectoryVendor(final ChaiEntry rootDSE) throws ChaiUnavailableException, ChaiOperationException {
final Set<String> interestedAttributes = new HashSet<>();
for (final DirectoryVendor directoryVendor : DirectoryVendor.values()) {
interestedAttributes.addAll(directoryVendor.getVendorFactory().interestedDseAttributes());
}
final SearchHelper searchHelper = new SearchHelper();
searchHelper.setAttributes(interestedAttributes.toArray(new String[interestedAttributes.size()]));
searchHelper.setFilter("(objectClass=*)");
searchHelper.setMaxResults(1);
searchHelper.setSearchScope(SearchScope.BASE);
final Map<String, Map<String, List<String>>> results = rootDSE.getChaiProvider().searchMultiValues("", searchHelper);
if (results != null && !results.isEmpty()) {
final Map<String, List<String>> rootDseSearchResults = results.values().iterator().next();
for (final DirectoryVendor directoryVendor : DirectoryVendor.values()) {
if (directoryVendor.getVendorFactory().detectVendorFromRootDSEData(rootDseSearchResults)) {
return directoryVendor;
}
}
}
return DirectoryVendor.GENERIC;
}
Aggregations