Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

JNDI Help needed

Thread view: 
Bryan - 12 Jul 2007 20:11 GMT
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.

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
Brandon McCombs - 14 Jul 2007 00:44 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.