r1294: A nice, large, commit...
[abartlet/samba.git/.git] / source4 / librpc / rpc / dcerpc_ntlm.c
index 398e3f1aa325d103c6d5df4d6bc985abd426015a..0f02669eb11b17db26553d8ad6b5bc9739625fc6 100644 (file)
@@ -33,12 +33,47 @@ NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p,
 {
        NTSTATUS status;
 
-       p->security_state.generic_state.user.domain = domain;
-       p->security_state.generic_state.user.name = username;
-       p->security_state.generic_state.user.password = password;
+       status = gensec_client_start(&p->security_state.generic_state);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status)));
+               return status;
+       }
 
+       status = gensec_set_domain(p->security_state.generic_state, domain);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("Failed to start set GENSEC client domain to %s: %s\n", 
+                         domain, nt_errstr(status)));
+               return status;
+       }
+
+       status = gensec_set_username(p->security_state.generic_state, username);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("Failed to start set GENSEC client username to %s: %s\n", 
+                         username, nt_errstr(status)));
+               return status;
+       }
+
+       status = gensec_set_password(p->security_state.generic_state, password);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("Failed to start set GENSEC client password: %s\n", 
+                         nt_errstr(status)));
+               return status;
+       }
+
+       status = gensec_start_mech_by_authtype(p->security_state.generic_state, DCERPC_AUTH_TYPE_NTLMSSP);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("Failed to start set GENSEC client NTLMSSP mechanism: %s\n",
+                         nt_errstr(status)));
+               return status;
+       }
+       
        status = dcerpc_bind_auth(p, DCERPC_AUTH_TYPE_NTLMSSP,
                                  uuid, version);
 
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(2, ("Failed to bind to pipe with NTLMSSP: %s\n", nt_errstr(status)));
+               return status;
+       }
+
        return status;
 }