public virtual void startTLS()
{
LdapMessage startTLS = MakeExtendedOperation(new LdapExtendedOperation(LdapConnection.START_TLS_OID, null), null);
int tlsID = startTLS.MessageID;
conn.acquireWriteSemaphore(tlsID);
try
{
if (!conn.areMessagesComplete())
{
throw new LdapLocalException(ExceptionMessages.OUTSTANDING_OPERATIONS, LdapException.OPERATIONS_ERROR);
}
// Stop reader when response to startTLS request received
conn.stopReaderOnReply(tlsID);
// send tls message
LdapResponseQueue queue = SendRequestToServer(startTLS, defSearchCons.TimeLimit, null, null);
LdapExtendedResponse response = (LdapExtendedResponse) queue.getResponse();
response.chkResultCode();
conn.startTLS();
}
finally
{
//Free this semaphore no matter what exceptions get thrown
conn.startReader();
conn.freeWriteSemaphore(tlsID);
}
return ;
}