String dnString = "uid=rebind.test,o=test";
DN userDN = DN.decode(dnString);
Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort());
s.setSoTimeout(6000);
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
BindRequestProtocolOp bindRequest =
new BindRequestProtocolOp(ByteString.valueOf(dnString),
3, ByteString.valueOf("password"));
LDAPMessage message = new LDAPMessage(1, bindRequest);
w.writeMessage(message);
message = r.readMessage();
BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0);
assertNotNull(DirectoryServer.getAuthenticatedUsers().get(userDN));
assertEquals(DirectoryServer.getAuthenticatedUsers().get(userDN).size(),
1);
// We occasionally run into
// ProtocolMessages.MSGID_LDAP_CLIENT_DUPLICATE_MESSAGE_ID, so we wait
// for previous ops to complete.
TestCaseUtils.quiesceServer();
bindRequest = new BindRequestProtocolOp(
ByteString.valueOf("cn=Directory Manager"), 3,
ByteString.valueOf("password"));
message = new LDAPMessage(1, bindRequest);
w.writeMessage(message);
message = r.readMessage();
bindResponse = message.getBindResponseProtocolOp();
assertEquals(bindResponse.getResultCode(), 0, message.toString());
assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN));