Thursday, 24 November 2011

connect ldap server using php over ssl

connect ldap server using php anonymous is fine.

But , when I try to over ssl using the code below.

<?php
 echo "<h3>LDAP query test</h3>";

 define("LDAP_USERBASE","cn=1019157,ou=students,ou=users,ou=comp,ou=destech,o=rgu");
 $username = "1019157";
 $password = "XXXXXX";
 $ldap = ldap_connect("10.52.1.246",636) or die("Can't connect to LDAP server");
 $user = "uid=" . $username . "," . LDAP_USERBASE;
 echo $user;
 ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3) ;
 if (ldap_bind($ldap, $user, $password)) {
  ldap_unbind($ldap);
  echo 'OK - Login valid';
 } else {
  die(ldap_error($ldap) . ' (' . ldap_errno($ldap) . ')');
 }
 ldap_close($ldap);

?>

it gave the error

Can't contact LDAP server (-1)

someone said that php doesn't support over ssl. really?

MSc project investigation report (outline)

1.1 Introduction
Generally talk about the internet history, what can we do use the internet...
1.2 Project Motivation
the project background, why we need to develop this project
1.3 Project Objectives
what this project can help the people and the developer.
2.1 Cloud computing
2.2 What is cloud computing
2.3 The layers
2.4 Development models
2.5 Discussion and evaluation of different cloud computing software tools and provider
3 Problems identified and proposed solutions
4 conclusion

References
Appendix

Thursday, 17 November 2011

LDAP authentication (continue)

When I log in the local machine and use jxplorer to connect LDAP server with the parameter below:

Host: 10.52.1.246                Port: 636

Protocol: LDAP v3

Base DN: O=RGU

Level: SSL+User+Password
User DN: cn=1019157,ou=students,ou=users,ou=comp,ou=destech,o=rgu
Password: the same with login to the Novell Network

I got the message box below:

But after that, when I want to connect again, the jxplorer report "simple bind failed: 10.52.1.246:636".


But when I log in the Novell Network with the same parameter:


The jxplorer report "simple bind failed: 10.52.1.246:636


Interested? Why?

Friday, 11 November 2011

MSc project (further development)

1. is it possible to access the project lab?
I may use it when the other labs were occupied by the other class.
Project lab is quiet.

The plan of next week( 11/11/2011 - 17/11/2011)
1. an outline of project investigation report.
2. finish the client-server communication example using gwt.
3. decide to use LDAP or not.

Saturday, 5 November 2011

study LDAP (continue)

I used java code to connect LDAP server in Anonymous methods, it said ok.  It cost me two afternoons.

I will try to use the SSL+User+Password methods.

Keep going...

The intelligent web technology course work has been posted to the modules. oh...




package
com.test.LDAP;


//import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

import
com.sun.org.apache.xerces.internal.impl.dv.util.*;


import
javax.naming.*;

import
javax.naming.directory.*;


import
java.security.MessageDigest;

import
java.security.NoSuchAlgorithmException;

import
java.util.Hashtable;

import
java.util.logging.Level;

import
java.util.logging.Logger;


 

/**

* Demonstrates how to create an initial context to an LDAP server

* using anonymous authentication (i.e. none).

*

* usage: java None

*/

class
LDAPTest {


public static void main(String[] args) {


System.
out.println("hello");

// Set up environment for creating initial context

Hashtable<String, Object> env =
new Hashtable<String, Object>(11);


env.put(Context.
INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

// env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

env.put(Context.
PROVIDER_URL, "ldap://10.52.1.246:389/o=RGU");


// Use anonymous authentication

env.put(Context.
SECURITY_AUTHENTICATION, "none");


try {

// Create initial context

DirContext ctx =
new InitialDirContext(env);

System.
out.println("authentication succeed");

ctx.close();

}
catch (javax.naming.AuthenticationException e){

System.
out.println("authentication failed");

e.printStackTrace();

}
catch (Exception e){

System.
out.println("unknown error");

e.printStackTrace();

}

}

}

Friday, 4 November 2011

The developing enviroment

How do I construct the developing enviroment?

The operation system. Linux or windows ?
Do I need to install a LDAP server like openLDAP for test?
How to connect LDAP server using programming?

Thursday, 3 November 2011

study LDAP

Try to connect the LDAP server of computing school using jxplorer.
It is fine when I use the C28 14 Desktop with the following parameters:

Host: 10.52.1.246
Protocol: LDAP v3
Port: 389
Base DN: O=RGU
Secutiry:
Level: Anonymous

But doesn't work when I choose the SSL+User+Password and doesn't work on my laptop neither in anonymous nor SSL+User+Password , and whatever I enable or disable the proxy.

Even I can connect the LDAP server and get some data, but what does those data means?
How those data can help this project?


After discussed with Dr. hui and follow his suggestion. I connected to the LDAP server successfully!
The parameters are:
Host: 10.52.1.246            Port: 636
Protocol:  LDAP v3
Base DN: O=RGU

Level:  SSL+User+Password
User DN: cn=1019157,ou=students,ou=users,ou=comp,ou=destech,o=rgu
Password: the same with login to the Novell Network

But when I tried at 10/11/2011, just a few days later, I used the same parameters, it didn't work!

Is it because I changed the password of Novell Network? But neither the old or the new password didn't work.

The error information is like below:

Error opening connection:
simple bind failed: 10.52.1.246:636

javax.naming.CommunicationException: simple bind failed: 10.52.1.246:636 [Root exception is javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Invalid Server Certificate: The server certificate could not be verified, as it has a bad chain back to a known CA.  raw error: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed]