Using Web Service to authenticate on LDAP

Since it' apparently not possible to authenticate with LDAP on my BlackBerry App, I'm trying to use a kind of workaround. Instead of authenticate directly on the LDAP Server, I want to use a Web Service in between. So it looks like this

App --calls--> Web Service --calls--> LDAP Server

So the Web Service should take the username and password given from the Application and send it to the LDAP Server. If its possible to sign in, the Web Service gets a TRUE as response and forward it to the App.

That's how it should work. But at the moment, when I call the Web Service from the App, I get following error:

SoapFault - faultcode: 'S:Server' faultstring: 'java.lang.NullPointerException' faultactor: 'null' detail: org.kxml2.kdom.Node@21e05a11

Seems like a Server problem but I don't know where :( Well, that's the Web Service I'm using:

import javax.ejb.Stateless;  
import javax.jws.WebService;  

import com.novell.ldap.LDAPConnection;  
import com.novell.ldap.LDAPException;  

@Stateless  
@WebService()  
public class ldapServiceBean implements ldapService {

    @Override
    public String error() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public boolean ldapLogin(String username, String password) {
         int ldapPort = LDAPConnection.DEFAULT_PORT;
         int ldapVersion = LDAPConnection.LDAP_V3;
         String ldapHost = "dc1.somehost ";
         String loginDN =
         "CN="+username+",OU=employee,OU=user,DC=somehost";

         byte[] passwordBytes = password.getBytes();
         LDAPConnection lc = new LDAPConnection();

         try {
             // connect to the server
             lc.connect( ldapHost, ldapPort );

             // authenticate to the server
             lc.bind( ldapVersion, loginDN, passwordBytes );
             System.out.println("Bind successful");

             return true;
         }
         catch( LDAPException e ) {
             if ( e.getResultCode() == LDAPException.NO_SUCH_OBJECT ) {
                 System.err.println( "Error: No such entry" );
             } else if ( e.getResultCode() ==
                 LDAPException.NO_SUCH_ATTRIBUTE ) {
                 System.err.println( "Error: No such attribute" );
             } else {
                 System.err.println( "Error: " + e.toString() );
             }
         }
        return false;
    }

And that's the method calling the Web Service

private static final String SOAP_ACTION = "";  
    private static final String METHOD_NAME = "ldapLogin";  
    private static final String NAMESPACE = "http://ldapproxy.somehost/";  
    private static final String URL = "http://myIP:8080/LDAPProxy/ldapServiceBeanService";  

...  


public boolean login(String username, String password) {


        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

        //SoapObject
        request.addProperty("username", username);
        request.addProperty("password", password);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        //envelope.dotNet = true;
        //envelope.bodyOut = request;
        envelope.setOutputSoapObject(request);       

        HttpTransport httpTransport = new HttpTransport(URL);
        try
        {

            httpTransport.call(SOAP_ACTION, envelope);

            System.out.println("request: " + httpTransport.requestDump);
            resultsRequestSOAP = (SoapObject) envelope.getResponse();

            return true;

        }catch(SoapFault sF){
            String error = sF.toString();
            Dialog.alert(error);
        }
        catch (Exception aE)
        {
            Dialog.alert("Connection failed");
            aE.printStackTrace ();
        }
        return false;

    }

What I found out so far: It seems that the webservice don't receives the username and password property. As I print them I get:

`CN=null, OU=employee, OU=...`

Like I've read at this post Web service recieves null parameters from application using ksoap method it seems ksoap have a problem with colons. I changed my NAMESPACE but without any success. Maybe I need to change my URL too. But how would I do this while I still need to use localhost ?

Answers


As always when doing LDAP bind testing this way, recall that the standard requires that a bind of a username, no password, is a successful Anonymous bind, so therefore you MUST validate for this case (empty password) on login attempts.


Need Your Help

Creating New Table by select query with sequental column names

sql sql-server

I have a table that contains column names like this;

how can I send a text from server to show it in TextView in android?

android

how do I can send a text from server(using php) to show it in TextView in the android