I am trying to connect to my remote oracle database, and it is locked down and has a white list of users and pc's that they can connect from. However, oracle is not providing OSUSER when I attempt the connection so I'm getting denied.
Here is how I am connecting:
public static final String CONNECTION_STRING = "jdbc:oracle:thin:@myip:port:db";
public static final java.util.Properties CONNECTION_PROPERTIES = new java.util.Properties();
static {
CONNECTION_PROPERTIES.setProperty("password","password");
CONNECTION_PROPERTIES.setProperty("user","dbuser");
CONNECTION_PROPERTIES.put("v$session.osuser", System.getProperty("user.name").toString());
try {
CONNECTION_PROPERTIES.put("v$session.machine", InetAddress.getLocalHost().getCanonicalHostName());
} catch (UnknownHostException e) {
System.out.println("Failed to determine hostname. Attempting with Localhost, this is unlikely to succeed.");
e.printStackTrace();
CONNECTION_PROPERTIES.put("v$session.machine", "localhost");
}
CONNECTION_PROPERTIES.put("v$session.program", "GDS_Reports");
}
and I make a connection like this:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection(GlobalConstants.CONNECTION_STRING, GlobalConstants.CONNECTION_PROPERTIES);
But the table reports these connections:
MACHINE 开发者_运维问答 OSUSER DBUSER FTIME
---------------------------------------- -------------------- -------------------- -----------------
wn7-18tl6m1.domain dbuser 02-SEP-2011 14:46
wn7-18tl6m1.domain dbuser 02-SEP-2011 14:46
wn7-18tl6m1.domain dbuser 02-SEP-2011 14:46
wn7-18tl6m1.domain dbuser 02-SEP-2011 14:46
Some Oracle JDBC drivers have a bug so that OSUSER is not set see the fixed bugs in 10.2.0.4 so you need to upgrade to a newer version to fix that.
Oracle doesn't provide the osuser - it has to be told it by the client. You can code it into the java program. Details here.
Obviously, because you can do this, it is a pretty pointless security measure to whitelist on it.
精彩评论