The searchFilter and searchCtls are n't properly provided.
Try this in your first code in this post.
//specify the LDAP search filter
String searchFilter = "(&(objectClass=*))";
//Specify the Base for the search
String searchBase = "O=Microsoft,C=COM";
SearchControls searchCtls = new SearchControls();
//federationBoundary ,objectClass ,sn - These are the fields which are available in LDAP. You can provide your own fields.
String returnedAtts[] = { "federationBoundary", "objectClass","sn" };
searchCtls.setReturningAttributes(returnedAtts);
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);