Saturday 26 December 2015

Linux - Steps to configure VNC server instance

Login to the Linux box and run below command : 
vncserver

It will ask for password and confirm password :
password : *****
confirm password : *****

Now you can connect to linux box through VNC viewer with created instance and password.

In case, it is not connecting, perform following commands :
  • su root
  • /etc/init.d/iptables save
  • /etc/init.d/iptables stop

Sunday 20 December 2015

Command to find ip address of linux box

sudo /sbin/ifconfig

Command to check open port

Linux :
netstat -ano | grep "1521" 

Windows : 
netstat -ano | find "1521"

Linux - Command for creating User

useradd <username>
passwd <username>
then type new password

Creating jar/zip/unzip file in Linux

Command for creating jar file in linux :
jar cvf <jar_name> <Java_file>

OIM - Delete loc file when getting loc error while starting the servers

Go to following location and delete .loc file:

For Admin Server:
/home/oracle/Oracle/Middleware/user_project/domain/base_domain/servers/AdminServer/tmp/

Delete file : AdminServer.loc

For SOA Server:
/home/oracle/Oracle/Middleware/user_project/domain/base_domain/servers/soa_server1/tmp/

Delete file : soa_server1.loc


For OIM Server:
/home/oracle/Oracle/Middleware/user_project/domain/base_domain/servers/oim_server1/tmp/

Delete file : oim_server1.loc

OIM - Frequently Used Scheduled Jobs.

Evaluate User Policies: This scheduled task evaluates the access policies.

Catalog Synchronization Job: To refresh CATALOG table.

Application Instance Post Delete Processing job: To delete application instance permanently.
Entitlement List: This scheduled task populates Entitlement in ENT_LIST table from lookup.

Task Timed Retry: This scheduled task creates a retry task for rejected tasks whose retry time has elapsed.

Entitlement Assignments: This scheduled task populates Entitlement Assignment. 

Bulk Load Post Process: This scheduled task starts post processing jobs for the Bulk Load Utility.

Automatically Unlock User: This scheduled task automatically unlocks an user after the specified number of days.

Refresh Role Membership: This scheduled job evaluates the changes in user-role membership rules and assigns users to roles based on the rules.

Refresh Admin Role Membership: This scheduled job evaluates the changes in user-admin role membership rules and assigns users to roles based on the rules.


SQL query to find SID in Oracle database.


sql> select sys_context('userenv','instance_name') from dual;


OIM - Set remoteEnabled is true for connecting SOA database


If you want to connect SOA database through java code then you first need to perform following steps :

Step1 :Go to below location :

/home/oracle/Oracle/Middleware/user_projects/domains/base_domain/bin

Step2 : Open "setDomainEnv.sh" file :
vi setDomainEnv.sh

Set remoteEnabled is true :
WLS_JDBC_REMOTE_ENABLED="-Dweblogic.jdbc.remoteEnabled=true"

Linux - Command to set bash path

 export PATH=/usr/bin:/usr/sbin:/bin

How to open sqlplus in linux.

Set environment variables: 
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1/
export PATH=/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin:$PATH

Go to following location :
/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin

Execute below command :
./sqlplus / as sysdba


Output :
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 28 14:31:37 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL>

Create auto increment field in Oracle database.

1. Create Table:


CREATE TABLE PERSON(
ID INT PRIMARY KEY,
FIRSTNAME VARCHAR2(20),
LASTNAME VARCHAR2(20)
)

2. Create Sequence:


CREATE SEQUENCE seq_person
MINVALUE 1
START WITH 1
INCREMENT BY 1
CACHE 10

3. Create Trigger, it will insert value for column "id" automatically:


CREATE OR REPLACE TRIGGER per_id
BEFORE INSERT ON person
FOR EACH ROW
BEGIN
  SELECT seq_person.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

Friday 18 December 2015

OIM - SQL Query to Hide Entity from Catalog.


UPDATE CATALOG SET IS_REQUESTABLE = 0 WHERE ENTITY_NAME = <ENTITY_NAME>;


Command to change Unix password

To change the root password:

sudo passwd

To change your user password:

passwd

To change other users password:

sudo passwd USERNAME

Change character set in oracle database - AL32UTF8

Login to the database and execute below commands :

SQL> SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER='NLS_NCHAR_CHARACTERSET';

VALUE
----------------------------------------
AL16UTF16


SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup Restrict;
ORACLE instance started.

Total System Global Area  430075904 bytes
Fixed Size                  2176448 bytes
Variable Size             343935552 bytes
Database Buffers           79691776 bytes
Redo Buffers                4272128 bytes
Database mounted.
Database opened.

SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;

Database altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.

Total System Global Area  430075904 bytes
Fixed Size                  2176448 bytes
Variable Size             343935552 bytes
Database Buffers           79691776 bytes
Redo Buffers                4272128 bytes
Database mounted.
Database opened.

SQL> SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER='NLS_NCHAR_CHARACTERSET';

VALUE
----------------------------------------
AL32UTF8

OIM - Plugin Register/Unregister Utility

Required Jar files :
wlfullclient.jar
oimclient.jar
commons-logging.jar
eclipselink.jar
spring.jar
authwl.conf

Java code:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
import java.util.Hashtable;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
import oracle.iam.platform.pluginframework.PluginException;
import oracle.iam.platformservice.api.PlatformService;
import oracle.iam.platformservice.exception.PlatformServiceAccessDeniedException;

public class PluginUtility {
   
    public static OIMClient getOIMConnection() {
        Hashtable<Object, Object> env = new Hashtable<Object, Object>();
        env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL,"weblogic.jndi.WLInitialContextFactory");
        env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,"<t3://oim url>");
        System.setProperty("java.security.auth.login.config", "<authwl.conf path>");
        System.setProperty("APPSERVER_TYPE", "wls");

        OIMClient oimClient = new OIMClient(env);
        try {
            oimClient.login("<username>", "<password>".toCharArray());

        } catch (LoginException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return oimClient;
    }
   
    public void register() {
        OIMClient oimClient = getOIMConnection();
        System.out.println(new Date() + " : Connected");
        System.out.println(new Date() + " : Registering the plugin");

        String fileName = "<zip file path>";

        PlatformService service = oimClient.getService(PlatformService.class);
        File zipFile = new File(fileName);
        FileInputStream fis;
        try {
            fis = new FileInputStream(zipFile);
            int size = (int) zipFile.length();
            byte[] b = new byte[size];
            int bytesRead = fis.read(b, 0, size);
            while (bytesRead < size) {
                bytesRead += fis.read(b, bytesRead, size - bytesRead);
            }
            fis.close();
            try {
                service.registerPlugin(b);
                System.out.println(new Date() + " :Plugin Registered");
            } catch (PlatformServiceAccessDeniedException e) {
                e.printStackTrace();
            } catch (PluginException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
   
    public void unregister(String pluginName, String pluginVer) {
        OIMClient oimClient = getOIMConnection();
        System.out.println(new Date() + " : Connected");
        PlatformService service = oimClient.getService(PlatformService.class);
        try {
            System.out.println(new Date() + " :Un Registering the plugin");
            service.unRegisterPlugin(pluginName,pluginVer);
            System.out.println(new Date() + " : Plugin unregistered");
        } catch (PlatformServiceAccessDeniedException e) {
            e.printStackTrace();
        } catch (PluginException e) {
            e.printStackTrace();
        }
    }
   
   
    public static void main(String[] args) {
        PluginUtility plugin = new PluginUtility();
        plugin.register();
        //plugin.unregister(<pluginName>,<version>);
    }
}

How to Register Custom ODL Logger in OIM?

Go to following location:

$MW_HOME/user_projects/domains/base_domain/config/fmwconfig/servers/oim_server1

Here we can find logging.xml

Open logging.xml and add the below snippet:

·         First add the below code under <log_handlers> </log_handlers>

<log_handler name='CustomLog' level='FINEST' class='oracle.core.ojdl.logging.ODLHandlerFactory'>
          <property name='logreader:' value='off'/>
          <property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/testlog.log'/>
          <property name='format' value='ODL-Text'/>
          <property name='useThreadName' value='true'/>
          <property name='locale' value='en'/>
          <property name='maxFileSize' value='5242880'/>
          <property name='maxLogSize' value='52428800'/>
          <property name='encoding' value='UTF-8'/>
   </log_handler>

·         Second add the below code under <logger> </logger>

  <logger name='EventHandlerLogger' level='TRACE:32' useParentHandlers='false'>
        <handler name='CustomLog'/>
        <handler name='console-handler'/>
  </logger>


Note: Once log handler and logger statements are added in logging.xml, execute ‘xmllint --valid logging.xml’ command to verify if all statements are added and there is no syntax error.

Now you can use below line in your java class:


private static ODLLogger logger = ODLLogger.getODLLogger("EventHandlerLogger");


OIM 11gR2PS3 - Assigning the “System Administrator” Role to the User


Step1 : Login to the self-service


Step2 : Click on "Manage" tab



 Step3 : Go to "Organisations" tab 


Step4 : Click on "Top" as Organization name


Step5 : Go to "Admin" tab and select “System Administrator” as Admin Role Name



  Step6 : Click on Assign button 




Step7 : Select user



Click on add selected and then click on “select” button


 Step8 : Now you can see that user in the User Memebers list , select the “include sub-orgs”



 Step9 : Check “include sub-orgs” and click on Apply button


Happy Learning!!!