Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
Showing
with 91 additions and 40 deletions
......@@ -46,7 +46,15 @@ public class AttributesList implements IStructuredContentProvider {
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())) {
// sql = "SELECT * FROM objectScope;";
......
......@@ -103,6 +103,7 @@ public class ConfigStore {
this.configs.put(label,cs);
this.storeConfigs();
}
/**
......
......@@ -102,7 +102,7 @@ public class ConnectionInfo {
name.setLayoutData(gr);
if (System.getProperty("os.name").equals("Mac OS X")) {
System.out.println("here");
name.addPaintListener(new LoadCfg(this));
} else {
name.addSelectionListener(new LoadCfg(this));
......@@ -163,7 +163,7 @@ public class ConnectionInfo {
port.setLayoutData(gr);
l = new Label(parent,SWT.NONE);
l.setText("Base ");
l.setText("Base (Leave blank for all)");
gr = new GridData();
gr.horizontalSpan = 1;
gr.horizontalAlignment = GridData.FILL;
......
......@@ -41,6 +41,7 @@ public class DirTree implements ITreeContentProvider {
public Object[] getChildren(Object obj) {
TreeObject to = (TreeObject) obj;
ResultSet namingContexts = null;
if (! to.getSQL) {
return to.children.values().toArray();
......@@ -80,7 +81,16 @@ public class DirTree implements ITreeContentProvider {
else {
try {
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())) {
sql = "SELECT dn FROM oneLevelScope;";
}
......@@ -119,11 +129,21 @@ public class DirTree implements ITreeContentProvider {
try {
//System.out.println("beginning sql");
//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");
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());
children.add(nto);
}
......
......@@ -39,7 +39,7 @@ import java.io.*;
*/
public class JdbcLdapBrowserApp {
public static final String VERSION = "2.0";
public static final String BUILD = "5506M";
public static final String BUILD = "6031M";
static JdbcLdapBrowserApp app;
......
......@@ -21,6 +21,9 @@ import org.eclipse.jface.viewers.*;
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 java.util.*;
import org.eclipse.jface.dialogs.MessageDialog;
......@@ -49,24 +52,25 @@ public class ResultLoader {
TreeObject to = (TreeObject) entrys.get(name);
if (to == null) {
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";
} else {
} else {
nname = name.substring(0,name.lastIndexOf(root.toString()));
}
StringTokenizer toker = new StringTokenizer(nname,",",false);
String[] dnparts = new String[toker.countTokens()];
int i=0;
while (toker.hasMoreTokens()) {
dnparts[i] = toker.nextToken();
i++;
}
DN dn = new DN(nname);
Iterator it = dn.getRDNs().iterator();
String[] dnparts = dn.explodeDN(false);
//try to find child
TreeObject tmp = root;
TreeObject parent = null;
for (i=dnparts.length-1;i>0;i--) {
for (int i=dnparts.length-1;i>0;i--) {
parent = tmp;
//System.out.println("i : " + i + ", len : " + dnparts.length);
///System.out.println("dn part : " + dnparts[i]);
......@@ -74,9 +78,14 @@ public class ResultLoader {
if (tmp == null) {
String fname = "";
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);
parent.addChild(dnparts[i],tmp);
......
......@@ -16,6 +16,7 @@ import java.net.MalformedURLException;
import java.util.*;
import com.novell.ldap.LDAPUrl;
import com.novell.ldap.util.DN;
import com.octetstring.jdbcLdap.jndi.*;
import java.util.regex.*;
......@@ -58,22 +59,33 @@ public class TreeObject {
public TreeObject(String name, TreeObject parent,String topBase) {
this.getSQL = true;
if (parent == null) {
this.base = name;
this.name = name;
if (parent == null || parent.getName().equalsIgnoreCase("RootDSE")) {
if (name.trim().length() == 0) {
this.base = name;
this.name = "RootDSE";
} else {
this.base = name;
this.name = name;
}
}
else {
//System.out.println("passed in name : " + name);
this.name = name.substring(0,name.indexOf(','));
if (name.endsWith(parent.getBase())) {
this.base = name;
}
else {
if (name.lastIndexOf(topBase) == -1) {
if (name.indexOf(',') == -1) {
name = "RootDSE";
base = " ";
} else {
this.name = new DN(name).explodeDN(false)[0];// name.substring(0,name.indexOf(','));
if (name.endsWith(parent.getBase()) || parent.getName().equalsIgnoreCase("RootDSE")) {
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 {
LDAPSearchConstraints constraints = null;
if (select.getJDBCConnection().getMaxSizeLimit() > 0) {
if (select.getJDBCConnection().getMaxSizeLimit() >= 0) {
constraints = con.getSearchConstraints();
constraints.setMaxResults(select.getJDBCConnection().getMaxSizeLimit());
}
if (select.getJDBCConnection().getMaxTimeLimit() > 0) {
if (select.getJDBCConnection().getMaxTimeLimit() >= 0) {
if (constraints == null) {
constraints = con.getSearchConstraints();
}
......@@ -103,12 +103,12 @@ public class RetrieveResults {
LDAPSearchConstraints constraints = null;
if (sql.getJDBCConnection().getMaxSizeLimit() > 0) {
if (sql.getJDBCConnection().getMaxSizeLimit() >= 0) {
constraints = con.getSearchConstraints();
constraints.setMaxResults(sql.getJDBCConnection().getMaxSizeLimit());
}
if (sql.getJDBCConnection().getMaxTimeLimit() > 0) {
if (sql.getJDBCConnection().getMaxTimeLimit() >= 0) {
if (constraints == null) {
constraints = con.getSearchConstraints();
}
......
......@@ -153,6 +153,7 @@ public class JdbcLdapInsert
tmp = SQL.substring(begin, end);
//tok = new StringTokenizer(tmp,",",false);
ltoks = explodeDN(tmp);
vals = new String[ltoks.size()];
offset = new int[ltoks.size()];
......@@ -162,7 +163,7 @@ public class JdbcLdapInsert
vals[i] = (String) it.next();
//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);
}
......@@ -176,7 +177,7 @@ public class JdbcLdapInsert
//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);
}
......
......@@ -220,7 +220,7 @@ public abstract class JdbcLdapSqlAbs implements JdbcLdapSql {
current = dnstr.charAt(i);
if (current == '\\') {
escaped = !escaped;
} else if (current == '\"' && !escaped) {
} else if ((current == '\"' || current == '\'') && !escaped) {
inquotes = !inquotes;
} else if (
(current == ',' || current == ';') && !escaped && !inquotes) {
......
......@@ -173,7 +173,7 @@ public class JdbcLdapUpdate extends com.octetstring.jdbcLdap.sql.statements.Jdbc
vals[i] = token.substring(token.indexOf(EQUALS) + 1);
//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);
}
......
......@@ -202,7 +202,7 @@ public class JdbcLdapUpdateEntry
attribName = attr.substring(0,attr.indexOf("="));
attribValue = attr.substring(attr.indexOf("=") + 1);
if (attribValue.charAt(0) == '"') {
if (attribValue.charAt(0) == '"' || attribValue.charAt(0) == '\'') {
attribValue = attribValue.substring(1,attribValue.length()-1);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment