use of com.sun.identity.sm.flatfile.SMSFlatFileObject in project OpenAM by OpenRock.
the class SMSRepositoryMig method migrate.
private static void migrate(ConnectionFactory factory, String host, int port, String binddn, String pw, String basedn, String flatfiledir) throws Exception {
// check args
if (port < 0 || binddn == null || binddn.length() == 0 || pw == null || pw.length() == 0 || basedn == null || basedn.length() == 0 || flatfiledir == null || flatfiledir.length() == 0) {
throw new IllegalArgumentException("SMSRepositoryMig: One or more invalid " + "arguments in constructor");
}
// Create the SMSFlatFileObject
SMSFlatFileObject smsFlatFileObject = new SMSFlatFileObject();
try (Connection conn = factory.getConnection()) {
// Loop through LDAP attributes, create SMS object for each.
ConnectionEntryReader res = conn.search(LDAPRequests.newSearchRequest("ou=services," + basedn, SearchScope.BASE_OBJECT, "(objectclass=*)", "*"));
while (res.hasNext()) {
if (res.isReference()) {
//ignore
res.readReference();
System.out.println("ERROR: LDAP Referral not supported.");
System.out.println("LDAPReferralException received");
} else {
SearchResultEntry entry;
try {
entry = res.readEntry();
createSMSEntry(smsFlatFileObject, entry.getName().toString(), entry.getAllAttributes());
} catch (LdapException e) {
System.out.println("ERROR: LDAP Exception encountered: " + e.toString());
e.printStackTrace();
}
}
}
}
}
Aggregations