Re: JNDI Help needed
 
Bryan wrote:
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:oracle:thin:@" + 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.
Suggestions?
Thanks,
Bryan