JNDI Help needed

B

Bryan

Hi,

I have some code that looks like this:

InitialContext ic = new InitialContext();

Reference ref = new Reference("javax.sql.DataSource",
"org.apache.commons.dbcp.BasicDataSourceFactory", null);

ref.add(new StringRefAddr("driverClassName", DRIVER_CLASS_NAME));

if (CONNECTION_STRING.length() == 0)
CONNECTION_STRING = "jdbc:eek:racle:thin:mad:" + svrName + ":1521:" + dbName;
ref.add(new StringRefAddr("url", CONNECTION_STRING));
ref.add(new StringRefAddr("username", CONNECTION_USERNAME));
ref.add(new StringRefAddr("password", CONNECTION_PASSWORD));

ic.rebind(dbName, ref);

This at some point appears to create a file on disk (on a windows xp)
called C:\.bindings that contains a bunch of database (in my case
oracle) connect info.

The problem I have is that if this file is created by someone running
the app as an administrator, and then someone who is not admin tries to
run this application later, it fails because it cannot update this file-
no permissions, and throws an error at the ic.rebind line.

So, having inherited this from someone only a day or two ago, Im not
sure what to do.

Can I put this info someplace else that is more suitable? Can I change
the permissions on what JNDI is writing to allow everyone access?

Suggestions?

Thanks,
Bryan
 
B

Brandon McCombs

Bryan said:
Hi,

I have some code that looks like this:

InitialContext ic = new InitialContext();

Reference ref = new Reference("javax.sql.DataSource",
"org.apache.commons.dbcp.BasicDataSourceFactory", null);

ref.add(new StringRefAddr("driverClassName", DRIVER_CLASS_NAME));

if (CONNECTION_STRING.length() == 0)
CONNECTION_STRING = "jdbc:eek:racle:thin:mad:" + svrName + ":1521:" + dbName;
ref.add(new StringRefAddr("url", CONNECTION_STRING));
ref.add(new StringRefAddr("username", CONNECTION_USERNAME));
ref.add(new StringRefAddr("password", CONNECTION_PASSWORD));

ic.rebind(dbName, ref);

This at some point appears to create a file on disk (on a windows xp)
called C:\.bindings that contains a bunch of database (in my case
oracle) connect info.

The problem I have is that if this file is created by someone running
the app as an administrator, and then someone who is not admin tries to
run this application later, it fails because it cannot update this file-
no permissions, and throws an error at the ic.rebind line.

Makes sense, the file is inheriting the permissions that are set on C:
using the ACEs on that part of the file system.
So, having inherited this from someone only a day or two ago, Im not
sure what to do.

Can I put this info someplace else that is more suitable? Can I change
the permissions on what JNDI is writing to allow everyone access?

If you want everyone to have access to it put it in a place that
everyone has access. Normally on a proper system this would be in
c:\windows\temp but if your administrators have mucked with the
permissions that may or may not work properly.

I don't know of anything in Java that let's you change the permissions
using the Windows API. There is a cacls.exe command that can change the
ACLs on a file but you should just have the file put in a temporary
location to handle the problem properly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top