Service Account concept was highly used during 9i version of OIM. In 11gR2 PS3 service account options are there from UI there is no option to move the Service Account to different users. here are the API sample for converting an OIM account to a Service Account and move the same to other user.
1. First Java Code: is to mark an account to Service Account
2. Second Java Code: is to get whether an account is Service Account or not.
3. Third Java Code: is to transfer a Service Account to other user.
After executing the third java code, the service account will be completely moved to a new target user.
1. First Java Code: is to mark an account to Service Account
2. Second Java Code: is to get whether an account is Service Account or not.
3. Third Java Code: is to transfer a Service Account to other user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getServiceAccount()throws Exception{ | |
loginWithCustomEnv(); //make a connection to OIM | |
ProvisioningService provAPI = (ProvisioningService)oimClient.getService(ProvisioningService.class); | |
List<Account> provisionedAccounts = provAPI.getAccountsProvisionedToUser(USR_KEY); | |
Account acc = null; | |
for(int i=0; i<provisionedAccounts.size(); i++){ | |
if (provisionedAccounts.get(i).getAccountStatus().equals("Provisioned") && provisionedAccounts.get(i).getAppInstance().getApplicationInstanceName().equals(APP_INST_NAME)){ | |
acc = provisionedAccounts.get(i); | |
break; | |
} | |
} | |
System.out.println("Service account ::"+ acc.isServiceAccount()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setServiceAccount() throws Exception{ | |
loginWithCustomEnv(); //make a connection to OIM | |
ProvisioningService provAPI = (ProvisioningService)oimClient.getService(ProvisioningService.class); | |
List<Account> provisionedAccounts = provAPI.getAccountsProvisionedToUser(USR_KEY); | |
Account acc = null; | |
for(int i=0; i<provisionedAccounts.size(); i++){ | |
if (provisionedAccounts.get(i).getAccountStatus().equals("Provisioned") && provisionedAccounts.get(i).getAppInstance().getApplicationInstanceName().equals(APP_INST_NAME)){ | |
acc = provisionedAccounts.get(i); | |
break; | |
} | |
} | |
acc.setServiceAccount(true); | |
provAPI.modify(acc); | |
System.out.println("done"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void moveServiceAccount()throws Exception{ | |
loginWithCustomEnv(); //make a connection to OIM | |
ProvisioningService provAPI = (ProvisioningService)oimClient.getService(ProvisioningService.class); | |
List<Account> provisionedAccounts = provAPI.getAccountsProvisionedToUser(SOURCE_USR_KEY); | |
Account acc = null; | |
for(int i=0; i<provisionedAccounts.size(); i++){ | |
if (provisionedAccounts.get(i).getAccountStatus().equals("Provisioned") && provisionedAccounts.get(i).getAppInstance().getApplicationInstanceName().equals(APP_INST_NAME)){ | |
acc = provisionedAccounts.get(i); | |
break; | |
} | |
} | |
if (acc.isServiceAccount()){ | |
tcUserOperationsIntf userAPI = oimClient.getService(tcUserOperationsIntf.class); | |
System.out.println("Account ID ::" + acc.getAccountID()); | |
userAPI.moveServiceAccount(Long.parseLong(acc.getAccountID()), TARGET_USR_KEY); | |
System.out.println("done"); | |
}else{ | |
System.out.println("not a service account"); | |
} | |
} |
Nice post with actual implementation for the service account management
ReplyDeleteHi Avijit,
ReplyDeleteNice blog. Could you please help me with Java code.
I was trying to find code in your blog as per your documentation but didnt able to find same.
Nice Post! Thanks for Sharing!
ReplyDelete