1. With Oracle and Eclipse (Indigo for example), i have installed hibernate plugins from jobss and tried to reverse engineer POJOs from Oracle DB. However hibernate configuration kept giving a message that "Fetching Children of Database..." on the lower right corner but was returning nothing. After a couple of hours of debugging, i figured that "hibernate.connection.username" in case of Oracle must be provided in UPPERCASE only, mixed or lower case will not work.
Please refer to KP Soft's website at https://kpsoft.digital/ for more information.
Wednesday, June 27, 2012
Tuesday, May 29, 2012
Forms 11g Webutil configuration
I did the following setup on linux, with some minor changes mostly path related items the steps below should work for windows server environment as well. Before making change take good backups of your environment.
Steps below are for Forms services 11gR2, steps may vary slightly for 11gR1. Please consult with oracle documentation for detailed steps.
please use reference document with Metalink DOC ID - 1093985.1
Steps below are for Forms services 11gR2, steps may vary slightly for 11gR1. Please consult with oracle documentation for detailed steps.
1.
Run create_webutil_db.sql
a.
CREATE USER webutil IDENTIFIED BY webutil
b.
Grant connect, resource to webutil
c.
Connect webutil/webutil
d.
@[ORACLE_HOME]/forms/create_webutil_db.sql
e.
Create public synonym webutil_db for
webutil.webutil_db;
f.
Connect sys as sysdba
g.
Grant execute on webutil_db to public;
2.
Copy and download Jacob from http://sourceforge.net/projects/jacob-project/files/jacob-project/1.14.3/jacob-1.14.3.zip/download
a.
Unzip the jacob download and place jacob.jar in
the ORACLE_HOME/forms/java directory
b.
backup sign_webuitl.bat script in [ORACLE_INSTANCE]/bin/sign_webutil.sh
c.
search for <Your KEYSTORE password> and
replace it with welcome1 (or something like this)
d.
search for <Your private key password> and
replace it with welcome1 (or something like this)
e.
Save the script and use it to sign jacob.jar as
below
f. [ORACLE_INSTANCE]/bin/sign_webutil.sh [ORACLE_HOME]/forms/java/jacob.jar
3.
Place jacob.dll in the
ORACLE_HOME/forms/webutil/ directory
4.
Jacob.dll in r2 – file names must be verified
against webutil.cfg file
a.
Place jacob-1.14.3-x86.dll in the
ORACLE_HOME/forms/webutil/win32 directory.
b.
Place jacob-1.14.3-x64.dll in the
ORACLE_HOME/forms/webutil/win64 directory
5.
Using weblogic EM console, Add
ORACLE_HOME/forms/java/frmall.jar to the CLASSPATH in the default.env
6.
Update formsweb.cfg webutil section with the
following if not already done:
a.
Add frmwebutil.jar and jacob.jar to the
WebutilArchive parameter in the [webutil] configuration section. For some
versions of 11g, this is already added.
b.
Specify
webutil_demo as the form to be run in the [webutil] configuration section
7.
Download webutil demo from link below, extract
and put the contents in a folder http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/196249.zip
8.
Copy ffisamp.dll to the
<ORACLE_HOME>\forms\webutil directory.
9.
Open your webutil.cfg file and add the following
line install.syslib.0.user.1=ffisamp.dll|40960|1.0|true
10.
If not already done do the following in
webutil.cfg
a.
transfer.appsrv.workAreaRoot=c:\temp
b.
transfer.appsrv.accessControl=TRUE
c.
transfer.database.enabled=TRUE
d.
transfer.appsrv.enabled=TRUE
11.
Add the folder in FORMS_PATH in enterprise
manager
12.
Replace db and run the following command:
a.
frmcmp.sh module=webutil_demo.fmb
module_type=form userid=webutil/webutil@<db> compile_all=yes
b.
FORMS_PATH variable and make sure webutil.pll
folder is available in the path or run the above command from command shell in
the folder where webutil.pll is available
13.
Restart opmnctl and wls_forms weblogic instance
14.
Run the webutil demo - http://server:port/forms/frmservlet?form=wu_fileupdown_demo&config=webutil
please use reference document with Metalink DOC ID - 1093985.1
Forms 11g DB connection
Add your DB connectivity information in
<oracle home of wls forms and reports>/FrmsInst1/config/tnsnames.ora
After adding it here, your users can now connect using their forms related username, password and DB tnsname
<oracle home of wls forms and reports>/FrmsInst1/config/tnsnames.ora
After adding it here, your users can now connect using their forms related username, password and DB tnsname
Monday, May 28, 2012
Oracle Forms 11gR2 installation instructions
Make sure there are no spaces in $PATH variable, this is not a problem with unix/linux generally.
Install openmotif and openmotif22 (prerequisites for Reports Server)
yum install openmotif
yum install openmotif22 (update yum repository as described in http://public-yum.oracle.com)
install jdk 1.6 update 30
download weblogic 10.3.5 + coherence + oepe package
install at /formsdisk/Oracle/Middleware
download ofm_frmrpts_linux_11 linux package from oracle and extract
cd Disk1
runInstall -ignoreSysPrereqs
skip software updates
select install only - do not configure
select Oracle middleware home - /formsdisk/Oracle/Middleware
Name Oracle Home Directory - FrmsHome
Click install
cd /formsdisk/Oracle/Middleware/Oracle_FRHome1/
config.sh
select "configure for deployment"
select and change name of oracle instance location and oracle instance name if needed
provide weblogic username/password - remember this one or write it down somewhere
I select all options available in the configure components screen
select auto options configuration
select do not use proxy configuration setting
uncheck use application identity store
click configure butting
Address any issues, I had the following issue and fixed it:
"Invalid JMX Port"
/etc/hosts file was not configured with ipaddress correctly as i had DHCP in one case and wireless connection in another and had to change this. If you have a static IP this may not be an issue
In case java update 25 or whatever in your formweb.cfg file is required below test url will automatically download it for you on IE browser, firefox can later load the same thing automatically as well. Vice-versa needs manual configuration in firefox
Test installation:
http://<server_hostname>:8889/forms/frmservlet?form=test.fmx&userid=&o therparams=useSDI=yes&lookAndFeel=oracle&colorScheme=blue
Install openmotif and openmotif22 (prerequisites for Reports Server)
yum install openmotif
yum install openmotif22 (update yum repository as described in http://public-yum.oracle.com)
install jdk 1.6 update 30
download weblogic 10.3.5 + coherence + oepe package
install at /formsdisk/Oracle/Middleware
download ofm_frmrpts_linux_11 linux package from oracle and extract
cd Disk1
runInstall -ignoreSysPrereqs
skip software updates
select install only - do not configure
select Oracle middleware home - /formsdisk/Oracle/Middleware
Name Oracle Home Directory - FrmsHome
Click install
cd /formsdisk/Oracle/Middleware/Oracle_FRHome1/
config.sh
select "configure for deployment"
select and change name of oracle instance location and oracle instance name if needed
provide weblogic username/password - remember this one or write it down somewhere
I select all options available in the configure components screen
select auto options configuration
select do not use proxy configuration setting
uncheck use application identity store
click configure butting
Address any issues, I had the following issue and fixed it:
"Invalid JMX Port"
/etc/hosts file was not configured with ipaddress correctly as i had DHCP in one case and wireless connection in another and had to change this. If you have a static IP this may not be an issue
In case java update 25 or whatever in your formweb.cfg file is required below test url will automatically download it for you on IE browser, firefox can later load the same thing automatically as well. Vice-versa needs manual configuration in firefox
Test installation:
http://<server_hostname>:8889/forms/frmservlet?form=test.fmx&userid=&o therparams=useSDI=yes&lookAndFeel=oracle&colorScheme=blue
Tuesday, May 22, 2012
External hard drive for both Mac and PC
I've been using external hard drives for a while now. Recently i
switched to Mac, I was able to use these hard disks and retrieve
documents and files. However i was not able to write to them with "Not
recognizing the external hard drive". Here is how i got around:
1. Remember that you loose all data while doing this, so back up on another hard drive
2. Connect your hard drive to a windows O/S computer with either vista or windows 7
3. Open windows explorer and right mouse click and select format
4. Pick exFAT format and 32 kb file block size
5. Format the disk
now it is ready to use. Remember that all data that you have on teh disk is lost and back it up on a different disk before you do any of this.
1. Remember that you loose all data while doing this, so back up on another hard drive
2. Connect your hard drive to a windows O/S computer with either vista or windows 7
3. Open windows explorer and right mouse click and select format
4. Pick exFAT format and 32 kb file block size
5. Format the disk
now it is ready to use. Remember that all data that you have on teh disk is lost and back it up on a different disk before you do any of this.
Tuesday, May 1, 2012
webcenter 10gR3 SSO with Portal Infra 10.1.4.2
Webcenter Installation - port 7780
Oracle Portal IM Installation - port 7777
Oracle Portal MT Installation - port 7778
Export ORACLE_HOME=/orclportal/ora/im
EXPORT ORACLE_SID=oradb10
[localhost oracle /orclportal/ora/im/sso/bin]$ ./ssoreg.sh -oracle_home_path /orclportal/ora/im -config_mod_osso TRUE -site_name localhost.localdomain:7780 -remote_midtier -config_file /orclportal/ora/im/Apache/Apache/conf/osso/myosso.conf
Oracle Portal IM Installation - port 7777
Oracle Portal MT Installation - port 7778
Export ORACLE_HOME=/orclportal/ora/im
EXPORT ORACLE_SID=oradb10
[localhost oracle /orclportal/ora/im/sso/bin]$ ./ssoreg.sh -oracle_home_path /orclportal/ora/im -config_mod_osso TRUE -site_name localhost.localdomain:7780 -remote_midtier -config_file /orclportal/ora/im/Apache/Apache/conf/osso/myosso.conf
Sunday, April 29, 2012
multiple oracle databases multiple listeners of one linux server
here are the db parameters
-------------------------------
db1 - port 1521
db2 - port 1526
listener.ora of db2 (named it exproc1 in listener tag)
----------------------
# listener.ora Network Configuration File: /wc1013/ora/wc1013db/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /wc1013/ora/wc1013db)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1526))
)
)
listener.ora of db1 (named EXTPROC0 in the listener tag)
-----------------------
# listener.ora Network Configuration File: /orclportal/ora/db10/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /orclportal/ora/db10)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oradb10.thekpsoft.com)
(ORACLE_HOME = /orclportal/ora/db10)
(SID_NAME = oradb10)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
-------------------------------
db1 - port 1521
db2 - port 1526
listener.ora of db2 (named it exproc1 in listener tag)
----------------------
# listener.ora Network Configuration File: /wc1013/ora/wc1013db/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /wc1013/ora/wc1013db)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1526))
)
)
listener.ora of db1 (named EXTPROC0 in the listener tag)
-----------------------
# listener.ora Network Configuration File: /orclportal/ora/db10/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /orclportal/ora/db10)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oradb10.thekpsoft.com)
(ORACLE_HOME = /orclportal/ora/db10)
(SID_NAME = oradb10)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
Sunday, April 22, 2012
Pentaho BI Suite Installation on Linux
Download pentaho-bi-suite-4.1.0-GA-i386.bin
create pentaho user and add it to sudo
sudo useradd -s /bin/bash -m pentaho
login as pentaho user
chmod u+x pentaho-bi-suite-4.1.0-GA-i386.bin
./pentaho-bi-suite-4.1.0-GA-i386.bin
In the wizard select custom option and select a path where you want pentaho to be installed and it will install all pre-reqs. I installed JDK, Tomcat and MySQL already. But it appears everything comes with the install and could be used unless you are on production.
sample users created are:
admin/welcome1(for http://localhost:8088)
joe/password (administrator)
suzy/password (system user)
create pentaho user and add it to sudo
sudo useradd -s /bin/bash -m pentaho
login as pentaho user
chmod u+x pentaho-bi-suite-4.1.0-GA-i386.bin
./pentaho-bi-suite-4.1.0-GA-i386.bin
In the wizard select custom option and select a path where you want pentaho to be installed and it will install all pre-reqs. I installed JDK, Tomcat and MySQL already. But it appears everything comes with the install and could be used unless you are on production.
sample users created are:
admin/welcome1(for http://localhost:8088)
joe/password (administrator)
suzy/password (system user)
mysql startup issues
In this note, I will document all startup issues that i had with mysql. Downloaded mysql community edition rpm 5.5.23 server and client packages and installed the using rpm -ivh <package names>
i tried to start using commands with mysqld but there were issues.
login as root and start mysql as below:
service mysql start
it worked.
Some other commands;
1. create user 'pbiuser'@'localhost' identified by 'welcome1';
2. create database 'bankdb';
3. create database bankdb;
4. grant usage on *.* to pbiuser identified by 'welcome1';
5. grant all privileges on bankdb.* to pbiuser@localhost;
i tried to start using commands with mysqld but there were issues.
login as root and start mysql as below:
service mysql start
it worked.
Some other commands;
1. create user 'pbiuser'@'localhost' identified by 'welcome1';
2. create database 'bankdb';
3. create database bankdb;
4. grant usage on *.* to pbiuser identified by 'welcome1';
5. grant all privileges on bankdb.* to pbiuser@localhost;
Monday, April 16, 2012
oracle portal 11g upgrade
Below are the steps for upgrading oracle portal 10.1.4.2 to 11.1.1.2
Db upgrade - 10.2.0.1 to 10.2.0.4 via patch 6810189
Install base version 11.1.1.2 (install software - do not configure option)
Install patchset 11.1.1.6 against 11.1.1.2 binaries
Run config.sh to create instance and domain
upgrade middle tier instance (ua)
Db upgrade - 10.2.0.1 to 10.2.0.4 via patch 6810189
- runInstaller -ignoreSysPrereqs
- select ORACLE_HOME that needs to be upgraded
- run root.sh as root at the end
- export ORACLE_HOME, ORACLE_SID and PATH
- dbua
- select DB that you want to upgrade and run through the wizard
Install base version 11.1.1.2 (install software - do not configure option)
Install patchset 11.1.1.6 against 11.1.1.2 binaries
Run config.sh to create instance and domain
- yum install openmotif
- yum install openmotif22 (for reports server)
upgrade middle tier instance (ua)
- select middle tier ORACLE_HOME of 10g portal instance
- select asinst_1 or whatever your new ORACLE_HOME of 11g weblogic instance that you created in step before this
Virtualbox permission denied error on mac host and linux guest
if you shared folder on the vm settings -> shared folders, can access this as root and are getting a permission denied problem as any other user, below is the list of steps for you :)
find uid (500) and gid (52000) of the user on the guest linux
login as root and run the following commands:
sudo mount -t vboxsf -o uid=500 Downloads /mnt/Downloads_win
or edit /etc/fstab and add the following at the end:
Downloads /mnt/Downloads_win vboxsf uid=500,gid=52000 0 0
Hope it works
find uid (500) and gid (52000) of the user on the guest linux
login as root and run the following commands:
sudo mount -t vboxsf -o uid=500 Downloads /mnt/Downloads_win
or edit /etc/fstab and add the following at the end:
Downloads /mnt/Downloads_win vboxsf uid=500,gid=52000 0 0
Hope it works
Saturday, March 31, 2012
Friday, March 30, 2012
Oracle SOA Suite 11.1.1.6 Samples, Tutorials
I came across some issues while importing samples from oracle jdev soa tutorials site at oracle/sun site. I was doing this for debugging few issues that i came across while i was working on a project over a period of time. Anyways, I uploaded some of the samples that were re-factored (mostly xml namespaces as this is where i had some issues) here. Please use them as needed.
All new comers to Oracle SOA should go through simple concepts (assignments, arrays, xquery, bpel, mediation, spring beans etc) thoroughly before you embark on large scale projects. This exercise will help strengthen your XML skills if they are rough. Brief description of projects that are included in the file are:
ArrayActivities
AssignActivities
HelloWorld BPEL
CallingWebService
OrderProcessor - Demonstrated Correlation - I will blog more about this some time later
SpringHelloWorld - Spring framework
Most names are self explanatory, again, new comers must get familiarized with weblogic enterprise manager for testing these services. Oracle site i referred above has very good documentation for introducing features.
All new comers to Oracle SOA should go through simple concepts (assignments, arrays, xquery, bpel, mediation, spring beans etc) thoroughly before you embark on large scale projects. This exercise will help strengthen your XML skills if they are rough. Brief description of projects that are included in the file are:
ArrayActivities
AssignActivities
HelloWorld BPEL
CallingWebService
OrderProcessor - Demonstrated Correlation - I will blog more about this some time later
SpringHelloWorld - Spring framework
Most names are self explanatory, again, new comers must get familiarized with weblogic enterprise manager for testing these services. Oracle site i referred above has very good documentation for introducing features.
Tuesday, March 13, 2012
Oracle Virtualbox Add new hard disk procedure
All oracle developers these days must get familiar with oracle virtual box concepts.. there is base images available from oracle for download for you to play around with. After downloading these images, you can add software to it and save it as a copy for you to transfer to different machines... how cool is that!!!
However if you are a novice, you need to get familiar with how to add disk space, to the base VMs. Most oracle base VM images come with just enough space, so for adding a new software (either middleware or database management tools for example) these instructions come handy.
However if you are a novice, you need to get familiar with how to add disk space, to the base VMs. Most oracle base VM images come with just enough space, so for adding a new software (either middleware or database management tools for example) these instructions come handy.
Click Settings -> Select Storage
Select IDE Controller -> Click Add Hard Disk
Click Create New Disk
Select VDI (Virtual box image format) or vmdk format and
continue through wizard and select or enter amount of space required.
Start VMDK
Login as root
You’ll see a message such as /dev/hdc doesn’t contain a
valid partition table
Mkdir /stagingDisk1
If this doesn’t work run mount /dev/hdc /stagingDisk1
Saturday, March 3, 2012
Android Emulator Usability Topics
Below is a list of usability topics on the android emulator:
1. Keyboard popup is more annoying on the emulator than it is on the actual device. In order to turn if off, do the following:
go to settings -> language and keyboard -> Uncheck android keyboard and other international language items
2. In order to add custom apk files on the emulator or the actual device, do the following:
go to settings -> applications -> Check unknown sources
3. In order to uninstall applications cleanly do the following:
go to settings -> applications -> manage applications -> select your application -> click uninstall (or clear data, clear cache etc) if this is what you want to do.
1. Keyboard popup is more annoying on the emulator than it is on the actual device. In order to turn if off, do the following:
go to settings -> language and keyboard -> Uncheck android keyboard and other international language items
2. In order to add custom apk files on the emulator or the actual device, do the following:
go to settings -> applications -> Check unknown sources
3. In order to uninstall applications cleanly do the following:
go to settings -> applications -> manage applications -> select your application -> click uninstall (or clear data, clear cache etc) if this is what you want to do.
Tuesday, February 21, 2012
OIM 11g DB password account expiry ORA-28001
On dev environments 11g DB introduced an account password expiry feature. This is very annoying as a OIM 11g developer as I don't want OIM passwords to expire. This article provides a procedure how to get around this issue.
OIM Schemas for which passwords need to be updated:
select * from dba_users (where expiry_date is within the range of your expiry time) and reset all teh passwords to the same value as before. Below is the list of accounts that have expired in my case
kpsoftoim_db_mds, kpsoftoim_db_oim, kpsoftoim_db_soainfra, kpsoftoim_db_orasdpm, kpsoftoim_db_oam
change the profile of 11g
----------------------------
ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED;
run select * from dba_profiles
and confirm the above updates to the profile
For each of the user accounts mentioned above, run the following:
----------------------------------------------------------------
select * from dba_users
-- mds
alter user kpsoftoim_db_mds identified by xxxxxx;
alter user kpsoftoim_db_mds account unlock;
-- oim
alter user kpsoftoim_db_oim identified by xxxxxx;
alter user kpsoftoim_db_oim account unlock;
-- soainfra
alter user kpsoftoim_db_soainfra identified by xxxxxx;
alter user kpsoftoim_db_soainfra account unlock;
-- orasdpm
alter user kpsoftoim_db_ias_orasdpm identified by xxxxxx;
alter user kpsoftoim_db_ias_orasdpm account unlock;
-- oam
alter user kpsoftoim_db_oam identified by xxxxxx;
alter user kpsoftoim_db_oam account unlock;
OIM Schemas for which passwords need to be updated:
select * from dba_users (where expiry_date is within the range of your expiry time) and reset all teh passwords to the same value as before. Below is the list of accounts that have expired in my case
kpsoftoim_db_mds, kpsoftoim_db_oim, kpsoftoim_db_soainfra, kpsoftoim_db_orasdpm, kpsoftoim_db_oam
change the profile of 11g
----------------------------
ALTER PROFILE DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED;
run select * from dba_profiles
and confirm the above updates to the profile
For each of the user accounts mentioned above, run the following:
----------------------------------------------------------------
select * from dba_users
-- mds
alter user kpsoftoim_db_mds identified by xxxxxx;
alter user kpsoftoim_db_mds account unlock;
-- oim
alter user kpsoftoim_db_oim identified by xxxxxx;
alter user kpsoftoim_db_oim account unlock;
-- soainfra
alter user kpsoftoim_db_soainfra identified by xxxxxx;
alter user kpsoftoim_db_soainfra account unlock;
-- orasdpm
alter user kpsoftoim_db_ias_orasdpm identified by xxxxxx;
alter user kpsoftoim_db_ias_orasdpm account unlock;
-- oam
alter user kpsoftoim_db_oam identified by xxxxxx;
alter user kpsoftoim_db_oam account unlock;
Monday, February 13, 2012
Installation of Android APK file App
Assuming that you have installed android SDK and tools as shown here, this article focuses on installing the individual apps or the apk files. Eclipse gives you an environment that will allow you to deploy android applications automatically. However one needs to use adb tool for installing app to the virtual device (simulator).
open a command prompt -> cmd in my case. I have this setup on a windows 7 machine. adb in my version (3.2) is located in platform-tools and not tools.
cd to C:\Android\android-sdk\platform-tools
adb install "c:\androidapps\kpsofthello.apk"
120 KB/s .....
Success
Android app is now installed.
open a command prompt -> cmd in my case. I have this setup on a windows 7 machine. adb in my version (3.2) is located in platform-tools and not tools.
cd to C:\Android\android-sdk\platform-tools
adb install "c:\androidapps\kpsofthello.apk"
120 KB/s .....
Success
Android app is now installed.
OIM 11g Create and disable accounts
/**
* @author VKanigicherla
*
* Utility for bulk loading users into the OIM system Data must be
* exported to an excel spreadsheet with the following attributes in the
* order specified below
* samid dn desc sid upn fn mi ln display office tel email title dept company loscr disabled
*
* In this example we used Active Directory to export user account data
* Ideally, connector reconciliation tasks must be used for importing users, in case you need
* do this manually for whatever reason, the below program could be used.
* Libraries needed are primarily from oim 11g environment and apache POI project for reading excel xml workbooks
*
*/
public class OimReconBulkUserLoad {
// Read the input feed from the excel file
public static String filename = "C:\\kpsoft\\junk\\Users1.xlsx";
public static List sheetData = new ArrayList();
public static FileInputStream fis = null;
public static ArrayList<OimBulkUser> oimUsers = new ArrayList<OimBulkUser>();
public static tcUtilityFactory ioUtilityFactory;
public static String updatedByUserName = "BULKLOADER";
static final Logger logger = Logger.getLogger(OimReconBulkUserLoad.class);
// OIM Env Data
public static String id;
public static OIMClient oimClient;
private static String OIMUserName = "prasad";
private static String OIMPassword = "xxxxxx";
private static final String OIM_PROVIDER_URL = "t3://sandbox-oim.kpsoft.org:14000/oim";
private static String OIMInitialContextFactory = "weblogic.jndi.WLInitialContextFactory";
private static UserManager userMgrSrvc = null;
private static tcOrganizationOperationsIntf orgSrvc = null;
private static String orgName = "Terminations";
public OimReconBulkUserLoad() {
super();
}
/**
* main control method for running the bulk load initiates connection with
* OIM reads the bulk load contents executes API for loading users cleans up
* the connection
*
* @param args
* @throws Exception
*/
public static void main(String args[]) throws Exception {
init();
readBulkLoadInputFile();
loadBulkLoadInputFile();
// printOimUsers();
execBulkLoadInputFile(orgName);
clean();
}
private static void printOimUsers() {
// TODO Auto-generated method stub
LOGGER("Printing OIM Users");
for (int i = 0; i < oimUsers.size(); i++) {
LOGGER(oimUsers.get(i).getSamAccountId());
}
}
/**
* creates a connection to the OIM with the passed in credentials
*
* @throws LoginException
*/
private static void init() throws LoginException {
LOGGER("Creating client....");
Hashtable env = new Hashtable();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, OIMInitialContextFactory);
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIM_PROVIDER_URL);
/**
* Passing environment in constructor disables lookup for environment in
* setup. In any case, we can always enforce manual environment settings
* by OIMClient.setLookupEnv(configEnv) method.
*/
oimClient = new OIMClient(env);
LOGGER("Logging in");
oimClient.login(OIMUserName, OIMPassword);
LOGGER("Log in successful");
// get the user Manager
userMgrSrvc = oimClient.getService(UserManager.class);
orgSrvc = oimClient.getService(tcOrganizationOperationsIntf.class);
}
/**
* parse the input file and iterate through the content
*
* @throws IOException
*/
protected static void readBulkLoadInputFile() throws IOException {
try {
fis = new FileInputStream(filename);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator rows = sheet.rowIterator();
// get rid of the title columns
if (rows.hasNext())
rows.next();
while (rows.hasNext()) {
XSSFRow row = (XSSFRow) rows.next();
Iterator cells = row.cellIterator();
List data = new ArrayList();
while (cells.hasNext()) {
XSSFCell cell = (XSSFCell) cells.next();
data.add(cell);
}
sheetData.add(data);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
}
}
}
/**
* create a arraylist of model user objects
*/
protected static void loadBulkLoadInputFile() {
//
// Iterates the data and print it out to the console.
// TODO - update these things based on teh excel spreadsheet header
//
int col_samid = 0;
int col_dn = 1;
int col_desc = 2;
int col_sid = 3;
int col_upn = 4;
int col_fn = 5;
int col_mi = 6;
int col_ln = 7;
int col_display = 8;
int col_office = 9;
int col_tel = 10;
int col_email = 11;
int col_title = 12;
int col_dept = 13;
int col_company = 14;
int col_loscr = 15;
int col_disabled = 16;
for (int i = 0; i < sheetData.size(); i++) {
List list = (List) sheetData.get(i);
OimBulkUser ssoUser = new OimBulkUser();
for (int j = 0; j < list.size(); j++) {
XSSFCell cell = (XSSFCell) list.get(j);
int cellType = cell.getCellType();
int cellColumnIndex = cell.getColumnIndex();
String cellValue = "";
if (cellType == HSSFCell.CELL_TYPE_NUMERIC) {
cellValue = Float.toString((float) cell
.getNumericCellValue());
} else if (cellType == HSSFCell.CELL_TYPE_STRING) {
cellValue = cell.getRichStringCellValue().getString();
}
if (cellColumnIndex == col_samid) {
ssoUser.setSamAccountId(cellValue);
} else if (cellColumnIndex == col_dn) {
ssoUser.setDistinguishedName(cellValue);
ssoUser.setOrganization(getOrganizationFromDN(cellValue));
} else if (cellColumnIndex == col_desc) {
ssoUser.setDescription(cellValue);
} else if (cellColumnIndex == col_sid) {
ssoUser.setSid(cellValue);
} else if (cellColumnIndex == col_upn) {
ssoUser.setUpnName(cellValue);
} else if (cellColumnIndex == col_fn) {
ssoUser.setFirstName(cellValue);
} else if (cellColumnIndex == col_mi) {
ssoUser.setMiddleName(cellValue);
} else if (cellColumnIndex == col_ln) {
ssoUser.setLastName(cellValue);
} else if (cellColumnIndex == col_display) {
ssoUser.setDisplayName(cellValue);
} else if (cellColumnIndex == col_office) {
ssoUser.setOffice(cellValue);
} else if (cellColumnIndex == col_tel) {
ssoUser.setTelephoneNumber(cellValue);
} else if (cellColumnIndex == col_email) {
ssoUser.setEmailAddress(cellValue);
} else if (cellColumnIndex == col_title) {
ssoUser.setTitle(cellValue);
} else if (cellColumnIndex == col_dept) {
ssoUser.setDepartmentName(cellValue);
} else if (cellColumnIndex == col_company) {
ssoUser.setCompany(cellValue);
} else if (cellColumnIndex == col_loscr) {
ssoUser.setLogikpsoftript(cellValue);
} else if (cellColumnIndex == col_disabled) {
ssoUser.setDisabledString(cellValue);
}
}
oimUsers.add(ssoUser);
}
}
private static String getOrganizationFromDN(String cellValue) {
// TODO Auto-generated method stub
String orgUnit = null;
try {
LdapName dnName = new LdapName(cellValue);
// get OU from the dn whis is always in teh second place 0
// (dc=org),1 (dc=kpsoft), 2, 3
orgUnit = dnName.get(3);
orgUnit = orgUnit.substring(orgUnit.indexOf('=') + 1);
} catch (InvalidNameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return orgUnit;
}
/**
* calls the create user API in SsoProvisioningServiceImpl logs the
* exceptions if any
*
* @throws SsoOrganizationException
*/
protected static void execBulkLoadInputFile(String orgName) {
for (OimBulkUser su : oimUsers) {
// do it only for organization specified
if (su.getOrganization().equals(orgName)) {
User blkUser = new User("");
// first name
blkUser.setAttribute("First Name", su.getFirstName());
// last name
blkUser.setAttribute("Last Name", su.getLastName());
// middle name
blkUser.setAttribute("Middle Name", su.getMiddleName());
// physicalDeliveryOfficeName
blkUser.setAttribute("Office", su.getOffice());
// telephoneNumber
blkUser.setAttribute("Telephone Number",
su.getTelephoneNumber());
// givenName
// displayName
blkUser.setAttribute("Display Name", su.getDisplayName());
// sAMAccountName
blkUser.setAttribute("User Login", su.getSamAccountId());
// title
blkUser.setAttribute("Title", su.getDescription());
blkUser.setAttribute("Email", su.getEmailAddress());
// system stuff
blkUser.setAttribute("Xellerate Type", "End-User");
// full time employee
blkUser.setAttribute("Role", "Full-Time Employee");
// get org key
long adUsersOimOrg = 1;
try {
adUsersOimOrg = Long.parseLong(findOimOrganizationKey(su
.getOrganization()));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// set the organization
blkUser.setAttribute("act_key", adUsersOimOrg);
// create the user now
UserManagerResult result;
UserManagerResult disableResult;
try {
result = userMgrSrvc.create(blkUser);
String usrKey = result.getEntityId();
LOGGER("User created in OIM for AD User: "
+ su.getSamAccountId() + " with user id: " + usrKey);
// if the user is disabled in AD export spreadsheet
// disable here as well
if (su.getDisabledString().equalsIgnoreCase("yes")) {
try {
disableResult = userMgrSrvc.disable(usrKey, false);
} catch (UserDisableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchUserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (ValidationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserAlreadyExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private static String findOimOrganizationKey(String orgName)
throws Exception {
LOGGER("Entering Method findOrganizationKey");
String organizationKey = null;
try {
LOGGER("Getting utility interfaces...");
tcOrganizationOperationsIntf moOrganizationUtility = (tcOrganizationOperationsIntf) oimClient
.getService(Thor.API.Operations.tcOrganizationOperationsIntf.class);
// find users
Hashtable mhSearchCriteria = new Hashtable();
if (orgName.startsWith("HR"))
mhSearchCriteria.put("Organizations.Organization Name", "HR*");
else
mhSearchCriteria
.put("Organizations.Organization Name", orgName);
tcResultSet moResultSet = moOrganizationUtility
.findOrganizations(mhSearchCriteria);
if (moResultSet == null || moResultSet.getRowCount() == 0)
throw new Exception("Organizations not found");
for (int i = 0; i < moResultSet.getRowCount(); i++) {
moResultSet.goToRow(i);
organizationKey = moResultSet
.getStringValue("Organizations.Key");
LOGGER("Organization Key is: " + organizationKey);
}
LOGGER("Done with getting organization key");
} catch (Exception e) {
LOGGER(e.getMessage());
throw new Exception(e);
}
LOGGER("Exiting Method");
return organizationKey;
}
/**
*
*/
private static void clean() {
LOGGER("OIM Logging out....");
// release resources
System.out.println("Releasing resources");
oimClient.logout();
LOGGER("OIM Log out successful");
}
public static void LOGGER(String msg) {
System.out.println("LOGGER >> " + msg);
}
}
Subscribe to:
Posts (Atom)