If you would like to delete the user through API here is the code to delete the user. This sample will delete a user with user id ' TUSER1' in OIM. When you delete a user the user gets de provisioned from all the targets he has been provisioned into.
package com.pts;
import java.util.Collection;
import java.util.HashMap;
import java.util.Hashtable;
import java.security.PrivilegedAction;
import com.thortech.xl.util.config.ConfigurationClient.ComplexSetting;
import com.thortech.xl.util.config.ConfigurationClient;
import com.thortech.xl.crypto.tcSignatureMessage;
import com.thortech.xl.crypto.tcCryptoUtil;
import com.thortech.xl.security.tcLoginException;
import com.thortech.xl.crypto.tcCryptoException;
import Thor.API.*;
import Thor.API.Operations.*;
import Thor.API.Exceptions.tcAPIException;
import Thor.API.Exceptions.*;
import Thor.API.tcResultSet;
import Thor.API.tcUtilityFactory;
import Thor.API.Security.LoginHandler.LoginSession;
import Thor.API.Security.ClientLoginUtility;
import Thor.API.Security.XLClientSecurityAssociation;
public class deProvisionUser {
private tcUtilityFactory utilityFactory;
private tcUserOperationsIntf userIntf;
/** Connect to OIM as a standalone client make conection
* In order for this to work when you execute the pgm you should have
* these java options
* -Djava.security.auth.login.config=C:\oracle\oim_server\xellerate\config\auth.conf
* -DXL.HomeDir=C:\oracle\oim_server\xellerate
*
* Change the path according to installation.
**/
public deProvisionUser() {
System.out.println(" ************* Inside Access Policy constructor ****************");
try{
ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
System.out.println(" Config is "+config.toString());
final Hashtable env = config.getAllSettings();
System.out.println(" Hash Table env is "+ env);
tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm","PrivateKey");
utilityFactory = new tcUtilityFactory(env, moSignature);
System.out.println("utilityFactory = " + utilityFactory);
}catch(Exception ee){
System.out.println(" Exception in Constructor " +ee);
ee.printStackTrace();
}
}
public void deprovision(String userID){
tcResultSet rset;
try{
userIntf=(tcUserOperationsIntf)utilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
// Now Lets get all the Active users in OIM , we can select which user
// to remove later
HashMap map = new HashMap();
map.put("Users.User ID",userID);
map.put("Users.Status","Active");
rset=userIntf.findUsers(map);
// Get the User Key for the User given his User ID
rset.goToRow(0);
long uKey=rset.getLongValue("Users.Key");
System.out.println(" Key for Given User IS " + uKey);
// Now get all the objects thats been provisioned for
// the user given user's Key
rset=userIntf.getObjects(uKey);
int count=rset.getRowCount();
String cNames[] = rset.getColumnNames();
for(int i=0;i
rset.goToRow(i);
}
}catch(Exception ee){
System.out.println(" Error in deprovision "+ ee);
ee.printStackTrace();
}
}
public static void main(String args[]){
String userID="TUSER1";
new deProvisionUser().deprovision(userID);
System.exit(0);
}
}
No comments:
Post a Comment