Hi,
I need to query the Oracle Internet Directory LDAP server for a User object. If the User is not found, an exception is thrown. I need to be able to test for the User object's existence in OID withouth an excpetion being thrown.
This is what I have right now:
sub = roc.getSubscriber(ctx, Util.IDTYPE_DEFAULT, null, new String[] { "*" });
User myUser = null;
myUser = sub.getUser(ctx, Util.IDTYPE_DN, p.getName(), new String[] { });
Again, if myUser is not found, an exception is thrown. I need to be able to test if myUser exists for a if - else conditional, i.e.
IF (myUser == null //this doesn't work - exception thrown before I get here) {
do something
} ELSE {
do something else
}
Here's more of the code I have right now:
RootOracleContext roc = null;
Subscriber sub = null;
roc = new RootOracleContext(ctx);
try {
// Using RootOracleContext to fetch the default realm
sub = roc.getSubscriber(ctx, Util.IDTYPE_DEFAULT, null, new String[] { "*" });
} catch (UtilException ue) {
out.println("Exception encountered when fetching Subscriber");
throw ue;
}
User myUser = null;
try {
// ctx - the DirContext
// Util.IDTYPE_SIMPLE - indicates the criteria used to look
// up the user.
// IDTYPE_SIMPLE = nickname
// IDTYPE_DN = DN
// IDTYPE_GUID = GUID of user
myUser =
sub.getUser(ctx, Util.IDTYPE_DN, p.getName(), new String[] { });
} catch (UtilException e) {
System.out.println(e.getMessage());
}
TIA,
Jim