削除プロビジョニング操作用のサンプルのGroovyスクリプト

次に、削除プロビジョニング操作を実行するためのサンプルのgroovyスクリプトを示します。

次のように削除スクリプトを登録します。

import java.sql.PreparedStatement;
import org.identityconnectors.framework.common.objects.*;
 
//Get the UID from the input map 'attributes'
String uid = attributes.get("__UID__").getValue().get(0);
System.out.println("[Delete-Groovy] Deleting user:: "+ uid);
 
try {
	//Delete data from child tables and then, main table
	//Delete user roles
	st = conn.prepareStatement("DELETE FROM USER_ROLE WHERE USERID=?");
	st.setString(1, uid);
	st.executeUpdate();
	st.close();
	
	//Delete user groups
	st = conn.prepareStatement("DELETE FROM USER_GROUP WHERE USERID=?");
	st.setString(1, uid);
	st.executeUpdate();
	st.close();
	
	//Delete user account
	st = conn.prepareStatement("DELETE FROM USERINFO WHERE USERID=?");
	st.setString(1, uid);
	st.executeUpdate();
} finally {
	if (st != null)
		st.close(); };
System.out.println("Deleted user:: "+ uid);