- }
-
- /* Client responds with a Kerberos ticket and an authenticator for
- * the principal "imap.hostname@realm" where "hostname" is the
- * first component of the host name of the server with all letters
- * in lower case and where "realm" is the Kerberos realm of the
- * server. The encrypted checksum field included within the
- * Kerberos authenticator should contain the server-provided
- * 32-bit number in network byte order.
- */
-
- strncpy(srvinst, ctl->server.names->id, (sizeof srvinst)-1);
- srvinst[(sizeof srvinst)-1] = '\0';
- for (p = srvinst; *p; p++) {
- if (isupper(*p)) {
- *p = tolower(*p);
- }
- }
+
+ buildSmbNtlmAuthRequest(&request,ctl->remotename,NULL);
+
+ if (outlevel >= O_DEBUG)
+ dumpSmbNtlmAuthRequest(stdout, &request);
+
+ memset(msgbuf,0,sizeof msgbuf);
+ to64frombits (msgbuf, (unsigned char*)&request, SmbLength(&request));
+
+ if (outlevel >= O_MONITOR)
+ report(stdout, "IMAP> %s\n", msgbuf);
+
+ strcat(msgbuf,"\r\n");
+ SockWrite (sock, msgbuf, strlen (msgbuf));
+
+ if ((gen_recv(sock, msgbuf, sizeof msgbuf)))
+ return result;
+
+ len = from64tobits ((unsigned char*)&challenge, msgbuf);
+
+ if (outlevel >= O_DEBUG)
+ dumpSmbNtlmAuthChallenge(stdout, &challenge);
+
+ buildSmbNtlmAuthResponse(&challenge, &response,ctl->remotename,ctl->password);
+
+ if (outlevel >= O_DEBUG)
+ dumpSmbNtlmAuthResponse(stdout, &response);
+
+ memset(msgbuf,0,sizeof msgbuf);
+ to64frombits (msgbuf, (unsigned char*)&response, SmbLength(&response));
+
+ if (outlevel >= O_MONITOR)
+ report(stdout, "IMAP> %s\n", msgbuf);
+
+ strcat(msgbuf,"\r\n");
+ SockWrite (sock, msgbuf, strlen (msgbuf));
+
+ if ((result = gen_recv (sock, msgbuf, sizeof msgbuf)))
+ return result;
+
+ if (strstr (msgbuf, "OK"))
+ return PS_SUCCESS;
+ else
+ return PS_AUTHFAIL;
+}
+#endif /* NTLM */