BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 01-25-2009, 03:27 PM   #1
growse
Knows Where the Search Button Is
 
Join Date: Jan 2008
Model: 9500
PIN: N/A
Carrier: Vodafone
Posts: 22
Default For some reason, LDAPQuery doesn't seem to be working. Anyone know why?

Please Login to Remove!

I had a great idea for a little app to synchronise my personal LDAP server with my BB (on BIS) contact list. I know C#, and sit next to a knowledgeable java guy at work, so thought I would give it a try.

So, I've got myself an app set up using the JDE 4.7 beta, and the first thing I thought to try was to connect to my LDAP over the internet using the net.rim.device.api.ldap namespace. I simply try to do an anonymous bind and then fetch all the entries for a particular base DN. Here's my code:

Java pastebin - collaborative debugging tool

I've highlighted the section that makes the LDAP connection. I've fixed the hostname / querytype rather than read it from the form to make troubleshooting a little easier.

When I run it in the simulator (9530) it comes up with "Success: 0", meaning that it thinks the query was successful and it found 0 records. The problem is, running my LDAP server in debug mode shows that it doesn't even connect to the LDAP server, and there definately are records behind that DN.

So, has anyone had this sort of trouble before? Annoyingly, I can't test it on a real device until RIM gives me some code signing keys.
Offline  
Old 02-04-2009, 06:09 AM   #2
growse
Knows Where the Search Button Is
 
Join Date: Jan 2008
Model: 9500
PIN: N/A
Carrier: Vodafone
Posts: 22
Default

Anyone?

I've tried doing a connection to a public LDAP server to request what should be about 114 records. Still no beans. Here's the code:

Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ldap.*;
import java.io.*;
import java.util.*;

/*
* BlackBerry applications that provide a user interface
* must extend UiApplication.
*/
public class LDAPSync extends UiApplication
{
private SyncMenuItem syncMenuItem;
private StartupScreen myScreen;
private SyncScreen syncScreen;

public static void main(String[] args)
{
//create a new instance of the application
//and start the application on the event thread
LDAPSync theApp = new LDAPSync();
theApp.enterEventDispatcher();
}

public LDAPSync()
{
syncMenuItem = new SyncMenuItem();
myScreen = new StartupScreen();
pushScreen(myScreen);
}

final class SyncMenuItem extends MenuItem
{
SyncMenuItem() {
super("Synchronize",0,0);
}

public void run() {
syncScreen = new SyncScreen(myScreen.getServerName(),myScreen.getBaseDN(),myScreen.getBindDN(),myScreen.getPassword(),myScreen.getSSL());
LDAPSync.getUiApplication().pushScreen(syncScreen);
}
}

final class SyncScreen extends MainScreen
{
public SyncScreen(String hostname, String baseDN, String bindDN, String password, boolean SSLconnection)
{
super();
add(new RichTextField("Fetching"));
try {
net.rim.device.api.ldap.LDAPQuery lq = new net.rim.device.api.ldap.LDAPQuery();
lq.setAuthType(LDAPQuery.LDAP_AUTH_ANONYMOUS);
lq.setConnectionType(LDAPQuery.LDAP_CONN_DEFAULT);
lq.setHost("ldap.telesec.de",389,"c=de");
lq.setScope(LDAPQuery.LDAP_SCOPE_SUB);
lq.addAttribute("entryUUID");
lq.start();
if (lq.getErrorCode() != LDAPQuery.LDAP_SUCCESS) {
add(new RichTextField("Failure: "+lq.getErrorCode()+' '+lq.getErrorMsg()));
add(new RichTextField(Integer.toString(LDAPQuery.LDAP_ERROR_SERVICE_UNAVAILABLE_EXCEPTION)+" SERVICE_UNAVAILABLE"));
} else {
add(new RichTextField("Success: "+Integer.toString(lq.getResultSize())));
Enumeration en = lq.getResults();
while(en.hasMoreElements()) {
LDAPEntry entry = (LDAPEntry)en.nextElement();
Enumeration attributes = entry.getAttributes();
while (attributes.hasMoreElements()) {
LDAPAttribute attribute = (LDAPAttribute)attributes.nextElement();
Enumeration values = attribute.getValues();
while (values.hasMoreElements()) {
Object value = values.nextElement();
if (value instanceof String) {
add(new RichTextField(String.valueOf(value)));
}
}
}
}
}
} catch (LDAPInvalidOperationException e) {
Dialog.alert(e.getMessage());
} catch (LDAPBadSyntaxException e) {
Dialog.alert(e.getMessage());
}
}
}

final class StartupScreen extends MainScreen
{
private BasicEditField ldapServerField;
private BasicEditField ldapBaseDNField;
private BasicEditField ldapBindDNField;
private PasswordEditField ldapPasswordField;
private CheckboxField ldapSSLCheck;

public String getServerName()
{
return ldapServerField.getText();
}
public String getBaseDN()
{
return ldapBaseDNField.getText();
}
public String getBindDN()
{
return ldapBindDNField.getText();
}
public String getPassword()
{
return ldapPasswordField.getText();
}
public boolean getSSL()
{
return ldapSSLCheck.getChecked();
}


protected void makeMenu(Menu menu, int instance) {
menu.add(syncMenuItem);
}
public StartupScreen()
{
//invoke the MainScreen constructor
super();

//add a title to the screen
LabelField title = new LabelField("LDAPSync",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);

//add the text
add(new RichTextField("v1 IGNORE ALL THIS, JUST DO MENU -> SYNC"));
ldapServerField = new BasicEditField("LDAP Server: ","");
ldapBaseDNField = new BasicEditField("Base DN: ","");
ldapBindDNField = new BasicEditField("Bind DN: ","");
ldapPasswordField = new PasswordEditField("Password: ","");
ldapSSLCheck = new CheckboxField("Use LDAPS ",false);

add(ldapServerField);
add(ldapBaseDNField);
add(ldapBindDNField);
add(ldapPasswordField);
add(ldapSSLCheck);
}
//Make sure we exit when the screen is closed
public boolean onClose()
{
System.exit(0);
return true;
}
}
}
Offline  
Old 02-12-2009, 02:49 AM   #3
jacytan
Thumbs Must Hurt
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Globe
Posts: 52
Default

your implementation of LDAP is more or less similar to my test application. first, i tried implementing it using the LDAP_AUTH_ANONYMOUS, but it never seemed to work and i read in some forums that there is a problem with the anonymous authentication with regards to the server security and stuff. so i tried changing the authentication from anonymous to simple, and it worked.

try changing your authentication from LDAP_AUTH_ANONYMOUS to LDAP_AUTH_SIMPLE. maybe this is the reason why it won't work. just give it a try.
Offline  
Old 02-17-2009, 08:39 AM   #4
growse
Knows Where the Search Button Is
 
Join Date: Jan 2008
Model: 9500
PIN: N/A
Carrier: Vodafone
Posts: 22
Default

Quote:
Originally Posted by jacytan View Post
your implementation of LDAP is more or less similar to my test application. first, i tried implementing it using the LDAP_AUTH_ANONYMOUS, but it never seemed to work and i read in some forums that there is a problem with the anonymous authentication with regards to the server security and stuff. so i tried changing the authentication from anonymous to simple, and it worked.

try changing your authentication from LDAP_AUTH_ANONYMOUS to LDAP_AUTH_SIMPLE. maybe this is the reason why it won't work. just give it a try.
I'll indeed give that a go and report back!
Offline  
Old 02-25-2009, 06:13 AM   #5
baskaraninfo
Knows Where the Search Button Is
 
baskaraninfo's Avatar
 
Join Date: Feb 2009
Location: Bangalore
Model: 9350
PIN: N/A
Carrier: Telstra
Posts: 29
Default For some reason, LDAPQuery doesn't seem to be working. Anyone know why?

When I run it in the simulator (9530) it comes up with "Success: 0".
The same thing as this thread meant for.

Do anybody have any suggestion/solution?
Offline  
Old 02-25-2009, 08:04 AM   #6
baskaraninfo
Knows Where the Search Button Is
 
baskaraninfo's Avatar
 
Join Date: Feb 2009
Location: Bangalore
Model: 9350
PIN: N/A
Carrier: Telstra
Posts: 29
Unhappy For some reason, LDAPQuery doesn't seem to be working. Anyone know why?

Initially it is asking for the user credentials, when we provide the user credentials it is showing the same error, "Success: 0", irrespective of the valid or invalid user details. Any help?
Offline  
Old 03-05-2009, 06:46 AM   #7
growse
Knows Where the Search Button Is
 
Join Date: Jan 2008
Model: 9500
PIN: N/A
Carrier: Vodafone
Posts: 22
Default

Quote:
Originally Posted by baskaraninfo View Post
Initially it is asking for the user credentials, when we provide the user credentials it is showing the same error, "Success: 0", irrespective of the valid or invalid user details. Any help?
I think we're taking it for granted that the simulator is completely broken. However, it seems that only anonymous auth is broken on the device and that credentials might work. Did you test only on the simulator?
Offline  
Old 03-09-2009, 05:55 AM   #8
baskaraninfo
Knows Where the Search Button Is
 
baskaraninfo's Avatar
 
Join Date: Feb 2009
Location: Bangalore
Model: 9350
PIN: N/A
Carrier: Telstra
Posts: 29
Question For some reason, LDAPQuery doesn't seem to be working. Anyone know why?

Thanks growse..

Yes, presently am only testing using the Simulator [Version 9530]. For anonymous and as well as with user credentials the results are seems to be the same.

I doubt whether it is actually tries connect to the LDAP or not.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Fluke Networks Versiv Modular Mainframe AS IS picture

Fluke Networks Versiv Modular Mainframe AS IS

$900.00



Agilent Keysight N3300A Electronic Load Mainframe *Parts Only- No Power* picture

Agilent Keysight N3300A Electronic Load Mainframe *Parts Only- No Power*

$275.00



Integrated Circuit IC Tester LCD Digital Display Multi-functional Integrated picture

Integrated Circuit IC Tester LCD Digital Display Multi-functional Integrated

$59.67



FUJITSU EML-03B MAINFRAME WITH 2X EML-150L ELECTRONIC LOAD MODULE picture

FUJITSU EML-03B MAINFRAME WITH 2X EML-150L ELECTRONIC LOAD MODULE

$289.99



Chroma 6312 DC Electronic Load Mainframe  picture

Chroma 6312 DC Electronic Load Mainframe

$239.96



ILX Lightwave LDC3908 Laser Diode Controller Mainframe with Key picture

ILX Lightwave LDC3908 Laser Diode Controller Mainframe with Key

$480.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.