Pages

Ads 468x60px

Thursday, July 26, 2012

Java: Get/Set Valid User Account of IBM Tivoli Access Manager (ITAM-eb)


This will help you to get/set valid user account of IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. For conection with IBM Tivoli Access Manager (ITAM-eb) visit:   http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html



import com.tivoli.pd.jadmin.PDUser;
import com.tivoli.pd.jutil.PDContext;
import com.tivoli.pd.jutil.PDMessages;

// service for TAM user
public class UserService {

private PDMessages msgs = new PDMessages();

// to get user account is valid or invalid
public boolean getValidAccount(String name) {
boolean valid = false;

try {
   // Initialize administration API Context
   ctxt = TAMConnection.InitializeContext();
PDUser pdUser = new PDUser(ctxt, name, msgs);
valid = pdUser.isAccountValid();
// Close administration API Context
TAMConnection.CloseContext(msgs);
}catch (Exception ex) {
ex.getMessage();
}
return valid;
}

// to set user account to valid or invalid
public void setValidAccount(String name, boolean valid) {
PDContext ctxt = null;

try {
// Initialize administration API Context
ctxt = TAMConnection.InitializeContext();
PDUser pdUser = new PDUser(ctxt, name, msgs);
pdUser.setAccountValid(ctxt, valid, msgs);
System.out.println(pdUser.isAccountValid());
// Close administration API Context
TAMConnection.CloseContext(msgs);

} catch (Exception ex) {
ex.getMessage();
}
}
}

No comments:

Post a Comment