fix gssapi ldap auth, r=standard8, a=standard8 bug 671827
authorDavid Bienvenu <bienvenu@nventure.com>
Fri, 28 Oct 2011 08:09:41 -0700
changeset 8962 1725775e93341b733bd9ec9cb1c9c950378ecd7f
parent 8961 b3fbc820d41d0c8cc7856331019b29baca77911f
child 8963 71e85d3e50f798a1f01e3b2a9ce549732511705e
push idunknown
push userunknown
push dateunknown
reviewersstandard8, standard8
bugs671827
fix gssapi ldap auth, r=standard8, a=standard8 bug 671827
ldap/xpcom/src/nsLDAPConnection.cpp
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -233,17 +233,17 @@ nsLDAPConnection::Close()
                   ldap_err2string(rc)));
       }
 #endif
       mConnectionHandle = nsnull;
   }
 
   PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("unbound\n"));
 
-  NS_ASSERTION(NS_SUCCEEDED(mThread->Shutdown()),
+  NS_ASSERTION(!mThread || NS_SUCCEEDED(mThread->Shutdown()),
                "Failed to shutdown thread cleanly");
 
   // Cancel the DNS lookup if needed, and also drop the reference to the
   // Init listener (if still there).
   //
   if (mDNSRequest) {
       mDNSRequest->Cancel(NS_ERROR_ABORT);
       mDNSRequest = 0;
@@ -691,16 +691,34 @@ NS_IMETHODIMP nsLDAPConnectionRunnable::
               // We don't want to notify callers that we are done, so
               // redispatch the runnable.
               // XXX do we need a timer?
               rv = thread->Dispatch(this, nsIEventTarget::DISPATCH_NORMAL);
               NS_ENSURE_SUCCESS(rv, rv);
               return NS_OK;
             }
           }
+          // If we're midway through a SASL Bind, we need to continue
+          // without letting our caller know what we're up to!
+          //
+          if (errorCode == LDAP_SASL_BIND_IN_PROGRESS) {
+            struct berval *creds;
+            ldap_parse_sasl_bind_result(
+              mConnection->mConnectionHandle, msgHandle,
+              &creds, 0);
+
+            nsCOMPtr<nsILDAPOperation> operation;
+            mConnection->mPendingOperations.Get((PRUint32)mOperationID, getter_AddRefs(operation));
+
+            NS_ENSURE_TRUE(operation, NS_ERROR_NULL_POINTER);
+
+            nsresult rv = operation->SaslStep(creds->bv_val, creds->bv_len);
+            if (NS_SUCCEEDED(rv))
+              return NS_OK;
+          }
           break;
         }
           // Error code handling in here
         default:
           return NS_OK;
       }
 
       // invoke the callback on the nsILDAPOperation corresponding to