+ if (ntlmssp_state->use_ccache) {
+ struct wbcCredentialCacheParams params;
+ struct wbcCredentialCacheInfo *info = NULL;
+ struct wbcAuthErrorInfo *error = NULL;
+ struct wbcNamedBlob auth_blob;
+ struct wbcBlob *wbc_next = NULL;
+ struct wbcBlob *wbc_session_key = NULL;
+ wbcErr wbc_status;
+ int i;
+
+ params.account_name = ntlmssp_state->user;
+ params.domain_name = ntlmssp_state->domain;
+ params.level = WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP;
+
+ auth_blob.name = "challenge_blob";
+ auth_blob.flags = 0;
+ auth_blob.blob.data = reply.data;
+ auth_blob.blob.length = reply.length;
+ params.num_blobs = 1;
+ params.blobs = &auth_blob;
+
+ wbc_status = wbcCredentialCache(¶ms, &info, &error);
+ if (error != NULL) {
+ wbcFreeMemory(error);
+ }
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ goto noccache;
+ }
+
+ for (i=0; i<info->num_blobs; i++) {
+ if (strequal(info->blobs[i].name, "auth_blob")) {
+ wbc_next = &info->blobs[i].blob;
+ }
+ if (strequal(info->blobs[i].name, "session_key")) {
+ wbc_session_key = &info->blobs[i].blob;
+ }
+ }
+ if ((wbc_next == NULL) || (wbc_session_key == NULL)) {
+ wbcFreeMemory(info);
+ goto noccache;
+ }
+
+ *next_request = data_blob(wbc_next->data, wbc_next->length);
+ ntlmssp_state->session_key = data_blob(
+ wbc_session_key->data, wbc_session_key->length);
+
+ wbcFreeMemory(info);
+ goto done;
+ }
+
+noccache:
+