зеркало из https://github.com/mozilla/gecko-dev.git
fix for 242789 fallback from v3 to v2 for ldap, r/sr=sspitzer, for baking on the trunk, with moa from dmose
This commit is contained in:
Родитель
ccd79648d7
Коммит
f45b3c7735
|
@ -486,9 +486,8 @@ nsLDAPConnection::InvokeMessageCallback(LDAPMessage *aMsgHandle,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// find the operation in question
|
||||
//
|
||||
nsISupports *data = mPendingOperations->Get(key);
|
||||
if (!data) {
|
||||
operation = NS_STATIC_CAST(nsILDAPOperation *, mPendingOperations->Get(key));
|
||||
if (!operation) {
|
||||
|
||||
PR_LOG(gLDAPLogModule, PR_LOG_WARNING,
|
||||
("Warning: InvokeMessageCallback(): couldn't find "
|
||||
|
@ -501,7 +500,6 @@ nsLDAPConnection::InvokeMessageCallback(LDAPMessage *aMsgHandle,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
operation = getter_AddRefs(NS_STATIC_CAST(nsILDAPOperation *, data));
|
||||
|
||||
// Make sure the mOperation member is set to this operation before
|
||||
// we call the callback.
|
||||
|
@ -722,7 +720,29 @@ CheckLDAPOperationResult(nsHashKey *aKey, void *aData, void* aClosure)
|
|||
switch (rv) {
|
||||
|
||||
case NS_OK:
|
||||
break;
|
||||
{
|
||||
PRInt32 errorCode;
|
||||
rawMsg->GetErrorCode(&errorCode);
|
||||
if (errorCode == LDAP_PROTOCOL_ERROR)
|
||||
{
|
||||
// maybe a version error, e.g., using v3 on a v2 server.
|
||||
// if we're using v3, try v2.
|
||||
if (loop->mRawConn->mVersion == nsILDAPConnection::VERSION3)
|
||||
{
|
||||
nsCAutoString password;
|
||||
loop->mRawConn->mVersion = nsILDAPConnection::VERSION2;
|
||||
ldap_set_option(loop->mRawConn->mConnectionHandle, LDAP_OPT_PROTOCOL_VERSION, &loop->mRawConn->mVersion);
|
||||
nsCOMPtr <nsILDAPOperation> operation = NS_STATIC_CAST(nsILDAPOperation *, NS_STATIC_CAST(nsISupports *, aData));
|
||||
// we pass in an empty password to tell the operation that it
|
||||
// should use the cached password.
|
||||
operation->SimpleBind(password);
|
||||
operationFinished = PR_FALSE;
|
||||
// we don't want to notify callers that we're done...
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_ERROR_LDAP_DECODING_ERROR:
|
||||
consoleSvc->LogStringMessage(
|
||||
|
|
|
@ -149,6 +149,16 @@ nsLDAPOperation::SimpleBind(const nsACString& passwd)
|
|||
{
|
||||
nsresult rv;
|
||||
nsCAutoString bindName;
|
||||
PRBool originalMsgID = mMsgID;
|
||||
// Ugly hack alert:
|
||||
// the first time we get called with a passwd, remember it.
|
||||
// Then, if we get called again w/o a password, use the
|
||||
// saved one. Getting called again means we're trying to
|
||||
// fall back to VERSION2.
|
||||
// Since LDAP operations are thrown away when done, it won't stay
|
||||
// around in memory.
|
||||
if (!passwd.IsEmpty())
|
||||
mSavePassword = passwd;
|
||||
|
||||
NS_PRECONDITION(mMessageListener != 0, "MessageListener not set");
|
||||
|
||||
|
@ -160,8 +170,15 @@ nsLDAPOperation::SimpleBind(const nsACString& passwd)
|
|||
("nsLDAPOperation::SimpleBind(): called; bindName = '%s'; ",
|
||||
bindName.get()));
|
||||
|
||||
// If this is a second try at binding, remove the operation from pending ops
|
||||
// because msg id has changed...
|
||||
if (originalMsgID)
|
||||
NS_STATIC_CAST(nsLDAPConnection *,
|
||||
NS_STATIC_CAST(nsILDAPConnection *,
|
||||
mConnection.get()))->RemovePendingOperation(this);
|
||||
|
||||
mMsgID = ldap_simple_bind(mConnectionHandle, bindName.get(),
|
||||
PromiseFlatCString(passwd).get());
|
||||
PromiseFlatCString(mSavePassword).get());
|
||||
|
||||
if (mMsgID == -1) {
|
||||
const int lderrno = ldap_get_lderrno(mConnectionHandle, 0, 0);
|
||||
|
@ -189,7 +206,6 @@ nsLDAPOperation::SimpleBind(const nsACString& passwd)
|
|||
|
||||
// make sure the connection knows where to call back once the messages
|
||||
// for this operation start coming in
|
||||
//
|
||||
rv = NS_STATIC_CAST(nsLDAPConnection *,
|
||||
NS_STATIC_CAST(nsILDAPConnection *,
|
||||
mConnection.get()))->AddPendingOperation(this);
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "nsILDAPConnection.h"
|
||||
#include "nsILDAPOperation.h"
|
||||
#include "nsILDAPMessageListener.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// 97a479d0-9a44-47c6-a17a-87f9b00294bb
|
||||
#define NS_LDAPOPERATION_CID \
|
||||
|
@ -96,7 +97,7 @@ class nsLDAPOperation : public nsILDAPOperation
|
|||
nsCOMPtr<nsILDAPConnection> mConnection; // connection this op is on
|
||||
|
||||
LDAP *mConnectionHandle; // cache connection handle
|
||||
|
||||
nsCString mSavePassword;
|
||||
PRInt32 mMsgID; // opaque handle to outbound message for this op
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче