Skip to main content

developerworkslabel >  Java technology  >  forumlabel  >  Java security  >  developerWorks

I am Unable to connect to AD server using SSL while changing the password    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

loginbox.header
 loginbox.welcomelabel loginbox.guestlabel
loginbox.signin
Permlink Replies: 0 - Pages: 1
indrajeet

Posts: 2
Registered: Jan 29, 2007 01:45:43 PM
I am Unable to connect to AD server using SSL while changing the password
Posted: Nov 10, 2009 11:25:27 AM
Click to report abuse...   Click to reply to this thread Reply
Hi,

I am Unable to connect to AD server using SSL while changing the password of AD Members.

Thanks in Advance. Please help.

Source Code:

public class ChangePass
{
public static void main (String[] args)
{

Hashtable env = new Hashtable();

String userName="username@domain.com";
String samUser="";

String oldPassword = "xxxxxx";
String newPassword = "yyyyyy";


Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty("javax.net.ssl.trustStore", "C:\\certnew.jks");
System.setProperty("javax.net.debug", "all");

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,userName);
env.put(Context.SECURITY_CREDENTIALS,oldPassword);

env.put("com.sun.jndi.ldap.connect.timeout", "90000");

env.put(Context.SECURITY_PROTOCOL,"ssl");

String ldapURL = "ldaps://CORP:636";
env.put(Context.PROVIDER_URL,ldapURL);

try {

DirContext ctx = new InitialDirContext(env);

/*********************************search***************************/

SearchControls searchCtls = new SearchControls();

String returnedAtts[]={};
searchCtls.setReturningAttributes(returnedAtts);

searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);

String searchFilter = "SAMAccountName=Indrajeet2_19630";
String searchBase = "DC=CORP,DC=exlservice,DC=com";

NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);

SearchResult sr = (SearchResult) answer.next();
samUser=sr.getName()+",";

/*****************************************************/

ModificationItem[] mods = new ModificationItem[1];

String newQuotedPassword = "\"" + newPassword + "\"";
byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");

mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("unicodePwd", newUnicodePassword));

ctx.modifyAttributes(samUser+searchBase, mods);

System.out.println("Changed Password for: " + userName);

ctx.close();

}
catch (NamingException e) {
System.err.println("Problem changing password: " );
e.printStackTrace();
}
catch (UnsupportedEncodingException e) {
System.err.println("Problem encoding password: " + e);
}

}

}

*******************************************************

Getting blow debug information:

keyStore is :
keyStore type is : jks
keyStore provider is :
init keystore
init keymanager of type SunX509
trustStore is: C:\certnew.jks
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert:
Subject: CN=ExlService, OU=Technology, O=ExlService (I) Pvt. Ltd., L=NOIDA, ST=U.P., C=IN, EMAILADDRESS=administrator@exlservice.com
Issuer: CN=ExlService, OU=Technology, O=ExlService (I) Pvt. Ltd., L=NOIDA, ST=U.P., C=IN, EMAILADDRESS=administrator@exlservice.com
Algorithm: RSA; Serial number: 0x22ca3bd6aa4cd39f42d925c88a462f39
Valid from Sat May 17 00:36:59 IST 2008 until Sat Sep 03 00:29:07 IST 2011

trigger seeding of SecureRandom
done seeding SecureRandom
%% No cached client session

ClientHello, TLSv1
RandomCookie: GMT: 1237529021 bytes = { 112, 42, 69, 160, 176, 183, 169, 66, 229, 132, 210, 7, 111, 69, 103, 160, 230, 167, 206, 247, 42, 196, 181, 182, 62, 156, 185, 43 }
Session ID: {}
Cipher Suites: SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
Compression Methods: { 0 }
***
write MD5 and SHA1 hashes: len = 73
0000: 01 00 00 45 03 01 4A C3 32 BD 70 2A 45 A0 B0 B7 ...E..J.2.p*E...
0010: A9 42 E5 84 D2 07 6F 45 67 A0 E6 A7 CE F7 2A C4 .B....oEg.....*.
0020: B5 B6 3E 9C B9 2B 00 00 1E 00 04 00 05 00 2F 00 ..>..+......../.
0030: 33 00 32 00 0A 00 16 00 13 00 09 00 15 00 12 00 3.2.............
0040: 03 00 08 00 14 00 11 01 00 .........
Thread-0, WRITE: TLSv1 Handshake, length = 73
write MD5 and SHA1 hashes: len = 98
0000: 01 03 01 00 39 00 00 00 20 00 00 04 01 00 80 00 ....9... .......
0010: 00 05 00 00 2F 00 00 33 00 00 32 00 00 0A 07 00 ..../..3..2.....
0020: C0 00 00 16 00 00 13 00 00 09 06 00 40 00 00 15 ............@...
0030: 00 00 12 00 00 03 02 00 80 00 00 08 00 00 14 00 ................
0040: 00 11 4A C3 32 BD 70 2A 45 A0 B0 B7 A9 42 E5 84 ..J.2.p*E....B..
0050: D2 07 6F 45 67 A0 E6 A7 CE F7 2A C4 B5 B6 3E 9C ..oEg.....*...>.
0060: B9 2B .+
Thread-0, WRITE: SSLv2 client hello message, length = 98
Raw write: length = 100
0000: 80 62 01 03 01 00 39 00 00 00 20 00 00 04 01 00 .b....9... .....
0010: 80 00 00 05 00 00 2F 00 00 33 00 00 32 00 00 0A ....../..3..2...
0020: 07 00 C0 00 00 16 00 00 13 00 00 09 06 00 40 00 ..............@.
0030: 00 15 00 00 12 00 00 03 02 00 80 00 00 08 00 00 ................
0040: 14 00 00 11 4A C3 32 BD 70 2A 45 A0 B0 B7 A9 42 ....J.2.p*E....B
0050: E5 84 D2 07 6F 45 67 A0 E6 A7 CE F7 2A C4 B5 B6 ....oEg.....*...
0060: 3E 9C B9 2B >..+
Thread-0, handling exception: java.net.SocketException: Software caused connection abort: recv failed
Thread-0, SEND TLSv1 ALERT: fatal, description = unexpected_message
Thread-0, WRITE: TLSv1 Alert, length = 2
Thread-0, Exception sending alert: java.net.SocketException: Software caused connection abort: socket write error
Thread-0, called closeSocket()
main, handling exception: java.net.SocketException: Software caused connection abort: recv failed
Problem changing password:
javax.naming.CommunicationException: simple bind failed: CORP:636 Root exception is java.net.SocketException: Software caused connection abort: recv failed
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:197)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2667)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:288)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)
at com.exl.ad.ChangePass.main(ChangePass.java:109)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:789)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.sun.jndi.ldap.Connection.writeRequest(Connection.java:393)
at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:334)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:192)
... 12 more

 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums