Ola Felagund, fiz como sugerido e também não deu certo:
env.put(Context.SECURITY_PRINCIPAL, "CN=Silvio,OU=Inf,OU=int,ou=novamerica,ou=com,ou=br");
env.put(Context.SECURITY_PRINCIPAL, "CN=Silvio,OU=Inf,DC=int,DC=novamerica,DC=com,DC=br");
Fiz uma pesquisa sobre a biblioteca sugerida JLDAP e encontrei o site http://developer.novell.com/documentation/samplecode/jldap_sample/index.htm
Fiz o seguinte exemplo:
[code]import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPException;
import java.security.Security;
public class MD5Bind {
public static void main( String[] args ) {
String ldapHost = "190.1.1.1";
int ldapPort = 389;
//String loginDN = "cn=Silvio,ou=Inf,o=int.novamerica.com.br";
//String loginDN = "cn=Silvio,o=int.novamerica.com.br";
//String loginDN = "CN=Silvio,OU=Inf,OU=int,ou=novamerica,ou=com,ou=br";
String loginDN = "CN=Silvio,OU=Inf,DC=int,DC=novamerica,DC=com,DC=br";
//String loginDN = "cn=Administrator,ou=Users,o=int.novamerica.com.br";
//String loginDN = "cn=Administrator,o=int.novamerica.com.br";
//String loginDN = "CN=Administrator,OU=Users,OU=int,ou=novamerica,ou=com,ou=br";
//String loginDN = "CN=Administrator,OU=Users,DC=int,DC=novamerica,DC=com,DC=br";
final String password = "123";
String[] mechanisms = {"DIGEST-MD5"};
LDAPConnection lc = new LDAPConnection();
try {
Security.addProvider(new com.novell.sasl.client.SaslProvider());
} catch(Exception e) {
System.err.println("Error loading security provider ("+e.getMessage()+")");
}
try {
lc.connect(ldapHost, ldapPort);
lc.bind(loginDN,"dn: "+loginDN, mechanisms, null, new BindCallbackHandler(password));
System.out.println("Digest-MD5 Sasl bind was successful.");
lc.disconnect();
} catch(LDAPException e) {
System.err.println("MD5Bind example failed");
System.err.println( "Error: " + e.toString() );
System.exit(1);
}
System.exit(0);
}
}[/code]
[code]import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import com.novell.security.sasl.RealmCallback;
import com.novell.security.sasl.RealmChoiceCallback;
import java.io.IOException;
class BindCallbackHandler implements CallbackHandler{
private char[] m_password;
BindCallbackHandler(String password) {
m_password = new char[password.length()];
password.getChars(0, password.length(), m_password, 0);
}
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i=0; i<callbacks.length; i++) {
if (callbacks[i] instanceof PasswordCallback) {
((PasswordCallback)callbacks[i]).setPassword(m_password);
} else if (callbacks[i] instanceof NameCallback) {
((NameCallback)callbacks[i]).setName(((NameCallback)callbacks[i]).getDefaultName());
} else if(callbacks[i] instanceof RealmCallback) {
((RealmCallback)callbacks[i]).setText(((RealmCallback)callbacks[i]).getDefaultText());
} else if (callbacks[i] instanceof RealmChoiceCallback) {
((RealmChoiceCallback)callbacks[i]).setSelectedIndex(0);
}
}
}
}[/code]
Tentei com todos os loginDN acima e ocorre o seguinte erro:
MD5Bind example failed
Error: LDAPException: Invalid Credentials (49) Invalid Credentials
LDAPException: Server Message: 8009030C: LdapErr: DSID-0C09043E, comment: AcceptSecurityContext error, data 0, vece
Alguem tem alguma ideia ?