Commit 9e308af2 authored by Clayton Donley's avatar Clayton Donley
Browse files

* Enabled DSMLv2 Support

* Added support for RootDSE in the SQL Directory Browser
* Setting the maximum number of entries to 0 results in no limit
* Single quotes are now recognized in INSERT/UPDATE/UPDATE ENTRY
parent 39540542
...@@ -46,7 +46,15 @@ public class AttributesList implements IStructuredContentProvider { ...@@ -46,7 +46,15 @@ public class AttributesList implements IStructuredContentProvider {
String sql; String sql;
sql = "SELECT * FROM objectScope;" + to.getBase(); String base = to.getBase();
if (base.equalsIgnoreCase("RootDSE")) {
base = " ";
}
sql = "SELECT * FROM objectScope;" + base;
// if (to.toString().equalsIgnoreCase(to.getBase())) { // if (to.toString().equalsIgnoreCase(to.getBase())) {
// sql = "SELECT * FROM objectScope;"; // sql = "SELECT * FROM objectScope;";
......
...@@ -103,6 +103,7 @@ public class ConfigStore { ...@@ -103,6 +103,7 @@ public class ConfigStore {
this.configs.put(label,cs); this.configs.put(label,cs);
this.storeConfigs(); this.storeConfigs();
} }
/** /**
......
...@@ -102,7 +102,7 @@ public class ConnectionInfo { ...@@ -102,7 +102,7 @@ public class ConnectionInfo {
name.setLayoutData(gr); name.setLayoutData(gr);
if (System.getProperty("os.name").equals("Mac OS X")) { if (System.getProperty("os.name").equals("Mac OS X")) {
System.out.println("here");
name.addPaintListener(new LoadCfg(this)); name.addPaintListener(new LoadCfg(this));
} else { } else {
name.addSelectionListener(new LoadCfg(this)); name.addSelectionListener(new LoadCfg(this));
...@@ -163,7 +163,7 @@ public class ConnectionInfo { ...@@ -163,7 +163,7 @@ public class ConnectionInfo {
port.setLayoutData(gr); port.setLayoutData(gr);
l = new Label(parent,SWT.NONE); l = new Label(parent,SWT.NONE);
l.setText("Base "); l.setText("Base (Leave blank for all)");
gr = new GridData(); gr = new GridData();
gr.horizontalSpan = 1; gr.horizontalSpan = 1;
gr.horizontalAlignment = GridData.FILL; gr.horizontalAlignment = GridData.FILL;
......
...@@ -41,6 +41,7 @@ public class DirTree implements ITreeContentProvider { ...@@ -41,6 +41,7 @@ public class DirTree implements ITreeContentProvider {
public Object[] getChildren(Object obj) { public Object[] getChildren(Object obj) {
TreeObject to = (TreeObject) obj; TreeObject to = (TreeObject) obj;
ResultSet namingContexts = null;
if (! to.getSQL) { if (! to.getSQL) {
return to.children.values().toArray(); return to.children.values().toArray();
...@@ -80,7 +81,16 @@ public class DirTree implements ITreeContentProvider { ...@@ -80,7 +81,16 @@ public class DirTree implements ITreeContentProvider {
else { else {
try { try {
con = browser.getConnection(to.getConId()); con = browser.getConnection(to.getConId());
sql = "SELECT dn FROM oneLevelScope;" + to.getBase(); String base = to.getBase();
if (base.equalsIgnoreCase("RootDSE")) {
sql = "SELECT namingContexts FROM objectScope; ";
namingContexts = con.createStatement().executeQuery(sql);
} else {
sql = "SELECT dn FROM oneLevelScope;" + to.getBase();
}
/*if (to.toString().equalsIgnoreCase(con.getBaseDN())) { /*if (to.toString().equalsIgnoreCase(con.getBaseDN())) {
sql = "SELECT dn FROM oneLevelScope;"; sql = "SELECT dn FROM oneLevelScope;";
} }
...@@ -119,11 +129,21 @@ public class DirTree implements ITreeContentProvider { ...@@ -119,11 +129,21 @@ public class DirTree implements ITreeContentProvider {
try { try {
//System.out.println("beginning sql"); //System.out.println("beginning sql");
//System.out.println("to.getConId: " + to.getConId()); //System.out.println("to.getConId: " + to.getConId());
ResultSet rs = con.createStatement().executeQuery(sql); ResultSet rs = null;
String dnAttrib = "DN";
if (namingContexts == null) {
rs = con.createStatement().executeQuery(sql);
} else {
rs = namingContexts;
dnAttrib = "namingContexts";
}
//System.out.println("retrieving sql"); //System.out.println("retrieving sql");
while (rs.next()) { while (rs.next()) {
TreeObject nto = new TreeObject(rs.getString("DN"),to,con.getBaseDN()); TreeObject nto = new TreeObject(rs.getString(dnAttrib),to,con.getBaseDN());
nto.setConId(to.getConId()); nto.setConId(to.getConId());
children.add(nto); children.add(nto);
} }
......
...@@ -39,7 +39,7 @@ import java.io.*; ...@@ -39,7 +39,7 @@ import java.io.*;
*/ */
public class JdbcLdapBrowserApp { public class JdbcLdapBrowserApp {
public static final String VERSION = "2.0"; public static final String VERSION = "2.0";
public static final String BUILD = "5506M"; public static final String BUILD = "6031M";
static JdbcLdapBrowserApp app; static JdbcLdapBrowserApp app;
......
...@@ -21,6 +21,9 @@ import org.eclipse.jface.viewers.*; ...@@ -21,6 +21,9 @@ import org.eclipse.jface.viewers.*;
import java.sql.*; import java.sql.*;
import com.novell.ldap.LDAPDN;
import com.novell.ldap.util.DN;
import com.novell.ldap.util.RDN;
import com.octetstring.jdbcLdap.jndi.*; import com.octetstring.jdbcLdap.jndi.*;
import java.util.*; import java.util.*;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
...@@ -49,24 +52,25 @@ public class ResultLoader { ...@@ -49,24 +52,25 @@ public class ResultLoader {
TreeObject to = (TreeObject) entrys.get(name); TreeObject to = (TreeObject) entrys.get(name);
if (to == null) { if (to == null) {
String nname; String nname;
if (name.lastIndexOf(root.toString()) == -1) { if (root.getName().equalsIgnoreCase("RootDSE")) {
nname = name;
} else if (name.lastIndexOf(root.toString()) == -1) {
nname = "cn=Unknown"; nname = "cn=Unknown";
} else { } else {
nname = name.substring(0,name.lastIndexOf(root.toString())); nname = name.substring(0,name.lastIndexOf(root.toString()));
} }
StringTokenizer toker = new StringTokenizer(nname,",",false);
String[] dnparts = new String[toker.countTokens()]; DN dn = new DN(nname);
int i=0; Iterator it = dn.getRDNs().iterator();
while (toker.hasMoreTokens()) {
dnparts[i] = toker.nextToken(); String[] dnparts = dn.explodeDN(false);
i++;
}
//try to find child //try to find child
TreeObject tmp = root; TreeObject tmp = root;
TreeObject parent = null; TreeObject parent = null;
for (i=dnparts.length-1;i>0;i--) { for (int i=dnparts.length-1;i>0;i--) {
parent = tmp; parent = tmp;
//System.out.println("i : " + i + ", len : " + dnparts.length); //System.out.println("i : " + i + ", len : " + dnparts.length);
///System.out.println("dn part : " + dnparts[i]); ///System.out.println("dn part : " + dnparts[i]);
...@@ -74,9 +78,14 @@ public class ResultLoader { ...@@ -74,9 +78,14 @@ public class ResultLoader {
if (tmp == null) { if (tmp == null) {
String fname = ""; String fname = "";
for (int j=i,m=dnparts.length;j<m;j++) { for (int j=i,m=dnparts.length;j<m;j++) {
fname += dnparts[j] + ","; fname += LDAPDN.escapeRDN(dnparts[j]) + ",";
}
if (! root.getName().equalsIgnoreCase("RootDSE")) {
fname += root.toString();
} else {
fname = fname.substring(0,fname.length() - 1);
} }
fname += root.toString();
tmp = new TreeObject(fname,parent,root.getBase(),false); tmp = new TreeObject(fname,parent,root.getBase(),false);
parent.addChild(dnparts[i],tmp); parent.addChild(dnparts[i],tmp);
......
...@@ -16,6 +16,7 @@ import java.net.MalformedURLException; ...@@ -16,6 +16,7 @@ import java.net.MalformedURLException;
import java.util.*; import java.util.*;
import com.novell.ldap.LDAPUrl; import com.novell.ldap.LDAPUrl;
import com.novell.ldap.util.DN;
import com.octetstring.jdbcLdap.jndi.*; import com.octetstring.jdbcLdap.jndi.*;
import java.util.regex.*; import java.util.regex.*;
...@@ -58,22 +59,33 @@ public class TreeObject { ...@@ -58,22 +59,33 @@ public class TreeObject {
public TreeObject(String name, TreeObject parent,String topBase) { public TreeObject(String name, TreeObject parent,String topBase) {
this.getSQL = true; this.getSQL = true;
if (parent == null) { if (parent == null || parent.getName().equalsIgnoreCase("RootDSE")) {
this.base = name; if (name.trim().length() == 0) {
this.name = name; this.base = name;
this.name = "RootDSE";
} else {
this.base = name;
this.name = name;
}
} }
else { else {
//System.out.println("passed in name : " + name); //System.out.println("passed in name : " + name);
this.name = name.substring(0,name.indexOf(',')); if (name.indexOf(',') == -1) {
name = "RootDSE";
if (name.endsWith(parent.getBase())) { base = " ";
this.base = name; } else {
} this.name = new DN(name).explodeDN(false)[0];// name.substring(0,name.indexOf(','));
else {
if (name.lastIndexOf(topBase) == -1) { if (name.endsWith(parent.getBase()) || parent.getName().equalsIgnoreCase("RootDSE")) {
this.base = name; this.base = name;
} else { }
this.base = name.substring(name.indexOf(',') + 1, name.lastIndexOf(topBase)); else {
if (name.lastIndexOf(topBase) == -1) {
this.base = name;
} else {
this.base = name.substring(name.indexOf(',') + 1, name.lastIndexOf(topBase));
}
} }
} }
......
...@@ -65,12 +65,12 @@ public class RetrieveResults { ...@@ -65,12 +65,12 @@ public class RetrieveResults {
LDAPSearchConstraints constraints = null; LDAPSearchConstraints constraints = null;
if (select.getJDBCConnection().getMaxSizeLimit() > 0) { if (select.getJDBCConnection().getMaxSizeLimit() >= 0) {
constraints = con.getSearchConstraints(); constraints = con.getSearchConstraints();
constraints.setMaxResults(select.getJDBCConnection().getMaxSizeLimit()); constraints.setMaxResults(select.getJDBCConnection().getMaxSizeLimit());
} }
if (select.getJDBCConnection().getMaxTimeLimit() > 0) { if (select.getJDBCConnection().getMaxTimeLimit() >= 0) {
if (constraints == null) { if (constraints == null) {
constraints = con.getSearchConstraints(); constraints = con.getSearchConstraints();
} }
...@@ -103,12 +103,12 @@ public class RetrieveResults { ...@@ -103,12 +103,12 @@ public class RetrieveResults {
LDAPSearchConstraints constraints = null; LDAPSearchConstraints constraints = null;
if (sql.getJDBCConnection().getMaxSizeLimit() > 0) { if (sql.getJDBCConnection().getMaxSizeLimit() >= 0) {
constraints = con.getSearchConstraints(); constraints = con.getSearchConstraints();
constraints.setMaxResults(sql.getJDBCConnection().getMaxSizeLimit()); constraints.setMaxResults(sql.getJDBCConnection().getMaxSizeLimit());
} }
if (sql.getJDBCConnection().getMaxTimeLimit() > 0) { if (sql.getJDBCConnection().getMaxTimeLimit() >= 0) {
if (constraints == null) { if (constraints == null) {
constraints = con.getSearchConstraints(); constraints = con.getSearchConstraints();
} }
......
...@@ -153,6 +153,7 @@ public class JdbcLdapInsert ...@@ -153,6 +153,7 @@ public class JdbcLdapInsert
tmp = SQL.substring(begin, end); tmp = SQL.substring(begin, end);
//tok = new StringTokenizer(tmp,",",false); //tok = new StringTokenizer(tmp,",",false);
ltoks = explodeDN(tmp); ltoks = explodeDN(tmp);
vals = new String[ltoks.size()]; vals = new String[ltoks.size()];
offset = new int[ltoks.size()]; offset = new int[ltoks.size()];
...@@ -162,7 +163,7 @@ public class JdbcLdapInsert ...@@ -162,7 +163,7 @@ public class JdbcLdapInsert
vals[i] = (String) it.next(); vals[i] = (String) it.next();
//temporary //temporary
if (vals[i].charAt(0) == '"') { if (vals[i].charAt(0) == '"' || vals[i].charAt(0) == '\'') {
vals[i] = vals[i].substring(1,vals[i].length()-1); vals[i] = vals[i].substring(1,vals[i].length()-1);
} }
...@@ -176,7 +177,7 @@ public class JdbcLdapInsert ...@@ -176,7 +177,7 @@ public class JdbcLdapInsert
//System.out.println("j : " + j + " i : " + i + " fields[i] : " + fields[i]); //System.out.println("j : " + j + " i : " + i + " fields[i] : " + fields[i]);
} }
else if (vals[i].charAt(0) == QUOTE) { else if (vals[i].charAt(0) == QUOTE || vals[i].charAt(0) == '\'') {
vals[i] = vals[i].substring(1,vals[i].length()-2); vals[i] = vals[i].substring(1,vals[i].length()-2);
} }
......
...@@ -220,7 +220,7 @@ public abstract class JdbcLdapSqlAbs implements JdbcLdapSql { ...@@ -220,7 +220,7 @@ public abstract class JdbcLdapSqlAbs implements JdbcLdapSql {
current = dnstr.charAt(i); current = dnstr.charAt(i);
if (current == '\\') { if (current == '\\') {
escaped = !escaped; escaped = !escaped;
} else if (current == '\"' && !escaped) { } else if ((current == '\"' || current == '\'') && !escaped) {
inquotes = !inquotes; inquotes = !inquotes;
} else if ( } else if (
(current == ',' || current == ';') && !escaped && !inquotes) { (current == ',' || current == ';') && !escaped && !inquotes) {
......
...@@ -173,7 +173,7 @@ public class JdbcLdapUpdate extends com.octetstring.jdbcLdap.sql.statements.Jdbc ...@@ -173,7 +173,7 @@ public class JdbcLdapUpdate extends com.octetstring.jdbcLdap.sql.statements.Jdbc
vals[i] = token.substring(token.indexOf(EQUALS) + 1); vals[i] = token.substring(token.indexOf(EQUALS) + 1);
//temporary //temporary
if (vals[i].charAt(0) == '"') { if (vals[i].charAt(0) == '"' || vals[i].charAt(0) == '\'') {
vals[i] = vals[i].substring(1,vals[i].length()-1); vals[i] = vals[i].substring(1,vals[i].length()-1);
} }
......
...@@ -202,7 +202,7 @@ public class JdbcLdapUpdateEntry ...@@ -202,7 +202,7 @@ public class JdbcLdapUpdateEntry
attribName = attr.substring(0,attr.indexOf("=")); attribName = attr.substring(0,attr.indexOf("="));
attribValue = attr.substring(attr.indexOf("=") + 1); attribValue = attr.substring(attr.indexOf("=") + 1);
if (attribValue.charAt(0) == '"') { if (attribValue.charAt(0) == '"' || attribValue.charAt(0) == '\'') {
attribValue = attribValue.substring(1,attribValue.length()-1); attribValue = attribValue.substring(1,attribValue.length()-1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment