Hi Gurus,
I am trying to get User Objects and do some operations like retrieve User information etc through a Plain Java Class.
1] Jar files that I am using are - sapj2eeclient.jar
com.sap.security.api.jar
logging.jar
this is the code that I am using.
Properties props = new Properties();
try{
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:50007");
props.put(Context.SECURITY_PRINCIPAL, "administrator");
props.put(Context.SECURITY_CREDENTIALS, "somil007");
props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services");
InitialContext ctx = new InitialContext(props);
String uid = "USER.PRIVATE_DATASOURCE.un:dhorions";
try {
if(UMFactory.isInitialized()){
UMFactory umf = UMFactory.getInstance();
IUserFactory userFactory = UMFactory.getUserFactory();
IUser user = userFactory.getUser(uid);
String username = user.getDisplayName();
String email = user.getEmail();
System.out.println(username);
System.out.println(email);
}
else {
System.out.println("Not Initialized");
}
}
catch (UMException e) {
String exmsg = null;
if(e.getNestedException()!= null)
exmsg = e.getNestedException().getLocalizedMessage();
else
exmsg = e.getLocalizedMessage();
System.out.println("UME EXception:" +exmsg);
e.printStackTrace();
}
}
catch(javax.naming.NamingException e) {
e.printStackTrace();
}
Now when I run this code I check "if UMFactory.isInitialized()" do operation else Print "some message" and I end up getting the message in "Not Initialized".
Can anyone help me with this ?
Thanks in Advance
Somil