Pages

Ads 468x60px

Thursday, July 26, 2012

Java: Set User Password and Show Users list of IBM Tivoli Access Manager (ITAM-eb)


This will help you to set user password and show all users list 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 java.util.ArrayList;
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 list of all users
public ArrayList<String> listUser() {
PDContext ctxt = null;
ArrayList<String> list = null;

try {
// Initialize administration API Context
ctxt = TAMConnection.InitializeContext();
list = PDUser.listUsers(ctxt,
PDUser.PDUSER_ALLPATTERN, PDUser.PDUSER_MAXRETURN, false,
msgs); // (context, pattern, maximum return, list by
// registry name, messages)
// Close administration API Context
TAMConnection.CloseContext(msgs);

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

// to set TAM user password
public void setPassword(String name, String password) {
PDContext ctxt = null;

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

No comments:

Post a Comment