Wednesday, April 22, 2009

IIS Integrated Authentication Gets Wrong User

Here's an interesting scenario we just went through and I thought I would share in case anyone else is searching for a fix to a similar issue... I recently wrote a set of web pages and cgi scripts for deploying OSB10gR3, WLI 9.2.2 and ALDSP3.0.1 assets from a web page. The idea is that developers can install assets to development themselves (without giving full admin access to the consoles) and not have to wait on the Middleware team to do installs for them. Part of the code checks the user that is hitting the page and validates they are authorized to run the install scripts in the environment they are trying to install to... The web pages are running in IIS Version 6.0 and I have Authenticated Integration enabled. The scripts worked great, except for 1 person, who was somehow hitting the page with a different userid than the one they were logged into Windows with... Turns out... We logged into his Windows XP machine and opened "User Accounts" in the Control Panel for his PC. Under the "Advanced" tab, there was an account set up for connecting to the specific server my pages are running on with the account name we saw when he tried hitting my web pages. We removed this entry, and tried hitting the page again (no reboot required) and the page recognized him as the corrct user. Simple fix, but it took a little while for us to find it.

Monday, April 20, 2009

Monday, March 30, 2009

Obtain a list of JPDs?

I'm expanding my search for help with a WLST script that will terminate all the aborted processes in WLI 9.2.2 I have an open case with Oracle, but we haven't come up with my "ideal" solution. What I have right now is a Java program that I can pass a JPD to, and it will terminate all the aborted processes for that JPD. This works ok, but I would like to find a way for the program to find all the JPDs in the environment and then parse through them. Ideally, all of this would be done in WLST, but I can live with Java if it gets the job done. Anyone out there have thoughts on how to do this? Unfortunately, I am a middleware guy and not a Java programmer, so I can't do much with this on my own. The code I have right now is included below:

import com.bea.wli.management.runtime.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Date;
import java.text.SimpleDateFormat;
import weblogic.management.MBeanHome;
import java.util.*;
import com.bea.wli.bpm.runtime.ProcessStatus;


public class TerminateProcess {


public static void main(String[] args){

    //Parameters to be configured
    //String JPDURI = "/IDXWEB/processes/Process.jpd";
    //String Provider_URL = "t3://localhost:7001";
    //String Security_Principal = "weblogic";
    //String Security_Credentials = "weblogic";



   if (args.length != 5) {
        System.out.println("Usage: ADMIN_URI JDP_URI ADMIN_USERNAME ADMIN_PASSWORD BATCH_COUNT");
        return;
    }
  String adminURL = args[0];
  System.out.println("Admin URL is$$$ "+adminURL);
  String jpdURI = args[1];
  System.out.println("jpdURI is$$$ "+jpdURI);
  String adminUserName = args[2];
  String adminPassword = args[3];
  int exitCount = Integer.parseInt(args[4]);
  boolean blnExitOnCount = false;//Flag to run the terminate process in batch. If true, it will
                                               //only the number of instances in the exitCount parameter.
                                               //If false, it will terminate all the instances of that JPD.

 try {
    String CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory";
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, CONTEXT_FACTORY );
    p.put(Context.PROVIDER_URL, adminURL );
    p.put(Context.SECURITY_PRINCIPAL,adminUserName);
    p.put(Context.SECURITY_CREDENTIALS,adminPassword);

    Context ctx = new InitialContext(p);

    MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

    Set s = home.getMBeansByType("ProcessRuntime");
    Iterator it = s.iterator();

    while (it.hasNext())
    {
            ProcessRuntimeMBean bean = (ProcessRuntimeMBean)it.next();

            //Query for JPD
            ProcessInstanceQuery query = new ProcessInstanceQuery();
            query.setStatus(ProcessStatus.ABORTED);
            query.setServiceURI(jpdURI);
   ProcessInstanceQueryResult info = bean.getProcessInstances(query);
            String[] instances = info.getInstanceIds();
            System.out.println("Instance Ids " + instances.toString());
            System.out.println("Instance Count " + instances.length);

            for(int i=0;i= exitCount-1))
                {
                    System.exit(0);
                }
            }
    }
    } catch (Exception ex) {
        System.out.println(ex);
        ex.printStackTrace();
    }

}

}

Monday, March 9, 2009

Ctrl-S in vi hangs my edit session

Sometimes I'm a bit stubborn and continue to work around an issue even though I know there must be a better way. Here's a great example: Working in vi, every now and again, I find myself hitting Ctrl-S when I want to save (Ctrl-S is a windows shortcut for Save for those that don't know...) And when you do that vi gets very unhappy. in fact, it seems to stop responding to all commands, and the only way I was ever able to "fix" my mistake was to close my connection to the server, and log back in. Then I would need to delete the .swp file vi creates when you are in an edit session, and then I could go back in and make all those changes over again (because, of course, I couldn't really save it...) I've been doing this sporadically, as needed, for the better part of 3 years. Today I got fed up and a quick google search (less than a minute) turned up a solution. Ctrl-Q will apparently put vi back in its place and accepting cryptic orders from me again.

Thursday, February 26, 2009

Virus shutting off access to outside world

A while back I ran into an issue when one of my PCs was infected with some kind of virus that stopped my access to go out to various virus protection websites, Google, etc. It turns out there is a file in Windows similar the one I am familiar with in UNIX called hosts. Here's a quick tip to help regaina ccess to the outside world if you run into a similar issue... C:\windows\system32\drivers\etc\hosts Make sure the only line in this file is "127.0.0.1 Localhost" If you've been infected by a spyware/Virus/Trojan/Adware... etc... it may have change this file so when you type in google.com or some other address it could redirect you over a specified ip, instead of looking up the address "normally."

Wednesday, February 25, 2009

My "virtual friend" Unnikrishnan Pillai, who I've worked with when calling Oracle Support in the past recently posted an example WLST script for creating JDBC datasources, which ended with "MultiDataSources coming soon..." (See Unni's Blog Post: http://unni-at-work.blogspot.com/2009/02/creating-jdbc-data-source-using-wlst_20.html ) I tried to add a comment to his blog with my own example WLST script for creating MultiDatasources, but received an error, so I figured I would post it here, and Unni... you can feel free to take this as a starting point and clean it up, or ignore it completely. But, I thought I would share in case there is anyone out there wondering how to do this. Feel free to post comments and/or ask questions if you need help with this script. The script creates a multiu datasource, pointing to 2 instances of an Oracle 10G RAC database...

connect('weblogic','weblogic','t3://localhost:70001')
edit()
startEdit(-1,-1,'false')

cd('/')
cmo.createJDBCSystemResource('DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1')
set('Name','DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('JNDINames',jarray.array([String('DS1')], String))
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1')
set('Url','jdbc:oracle:thin:@myDBServer1:1521:myDBSchema1')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCConnectionPoolParams/DS1')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1/Properties/user') set('Value','myUser')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS1')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2')
set('Name','DS2')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('JNDINames',jarray.array([String('DS2')], String))
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2')
set('Url','jdbc:oracle:thin:@myDBServer2:1521:myDBSchema2')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCConnectionPoolParams/DS2')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2/Properties/user')
set('Value','slims_upt')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS2')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCSystemResource('MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS')
set('Name','MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS/JDBCDataSourceParams/MultiDS')
set('JNDINames',jarray.array([String('MultiDS')], String))
set('AlgorithmType','Load-Balancing')
set('DataSourceList','DS1,DS2')
cd('/JDBCSystemResources/MultiDS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

activate()

Thursday, January 29, 2009

java.lang.NoSuchMethodError: getWLSTOptions

Ok, this is an odd one, and my friends at Oracle are working on it, but we have no resolution yet. We have an AquaLogic Service Bus domain that consists of an Admin Server on HostA and a Managed Server on HostB. To start and stop the Admin Server, we use the provided shell scripts (RH Linux 4.0 ES) (startWebLogic.sh, stopWebLogic.sh) This has all been working fine for months.... Then, all of a sudden, when we try to stop the Admin weblogic server running the stopWebLogic.sh script and receive the following output: Stopping Weblogic Server... Problem invoking WLST - java.lang.NoSuchMethodError: getWLSTOptions Done What happened? I'm not sure yet, but if anyone has any thoughts, I'm all EARs ;)

Thursday, January 22, 2009

WLST script without a plain text password

One of the things that has annoyed me about WLST is the seemingly missing method of being able to invoke a WLST script without having a plain text userid and password either in the script or in a properties file. I came across a great post on the Oracle Blogs today by Bola Kothandaraman that describes how you can have a WLST script without having a plan text username and password to your admin Server. It's similar to the boot.properties file, but there are some nuances of this method that are described pretty well in this post (at least I think they are... see my current script issue below): http://blogs.oracle.com/bala/2008/09/encrypt_the_credentials_when_r.html UPDATE: I originally had posted that I was having issues with this method, but I found my problem, and it was a super dumb mistake on my part which I fixed and tested this morning. The method described above is working like a charm and I'm happy to understand how to use WLST without a plain text username and password now.

Wednesday, January 7, 2009

Deleting All Tables in a MySQL database

I recently came into a scenario where I wanted to delete all the tables in my MySQL 5.x database, but didn't want to have to drop and recreate the database (because I didn't have access to do this and was too impatient to wait for the help...) and I didn't want to have to manually enter in 50+ tables each time I needed to clean up. I finally figured out a decent solution... I grep the output from the mysqldump command, looking for only the lines that begin with the word DROP (i.e. Drop table such-and-such) and pipe those lines back into mysql. The result is something like the following, where you fill in the username, password and database with your own information... mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE] grep ^DROP mysql -u [USERNAME] --password=[PASSWORD] [DATABASE]