libwbclient: add wbcCheckTrustCredentials()
[ira/wip.git] / source3 / nsswitch / libwbclient / wbc_pam.c
index 1164ab173a50e47e1030c2f08ebbd3331da968be..f6a355a413f9245e1283b2d9015a15f36aceda11 100644 (file)
@@ -324,7 +324,7 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
                                WBFLAG_PAM_LMKEY;
 
                if (params->password.response.lm_length &&
-                   params->password.response.lm_data) {
+                   !params->password.response.lm_data) {
                        wbc_status = WBC_ERR_INVALID_PARAM;
                        BAIL_ON_WBC_ERROR(wbc_status);
                }
@@ -384,8 +384,7 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
                }
                break;
        default:
-               wbc_status = WBC_ERR_INVALID_PARAM;
-               BAIL_ON_WBC_ERROR(wbc_status);
+               break;
        }
 
        if (cmd == 0) {
@@ -420,3 +419,55 @@ done:
 
        return wbc_status;
 }
+
+/** @brief Trigger a verification of the trust credentials of a specific domain
+ *
+ * @param *domain      The name of the domain, only NULL for the default domain is
+ *                     supported yet. Other values than NULL will result in
+ *                     WBC_ERR_NOT_IMPLEMENTED.
+ * @param error        Output details on WBC_ERR_AUTH_ERROR
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcCheckTrustCredentials(const char *domain,
+                               struct wbcAuthErrorInfo **error)
+{
+       struct winbindd_request request;
+       struct winbindd_response response;
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       const char *name_str;
+
+       if (domain) {
+               /*
+                * the current protocol doesn't support
+                * specifying a domain
+                */
+               wbc_status = WBC_ERR_NOT_IMPLEMENTED;
+               BAIL_ON_WBC_ERROR(wbc_status);
+       }
+
+       ZERO_STRUCT(request);
+       ZERO_STRUCT(response);
+
+       /* Send request */
+
+       wbc_status = wbcRequestResponse(WINBINDD_CHECK_MACHACC,
+                                       &request,
+                                       &response);
+       if (response.data.auth.nt_status != 0) {
+               if (error) {
+                       wbc_status = wbc_create_error_info(NULL,
+                                                          &response,
+                                                          error);
+                       BAIL_ON_WBC_ERROR(wbc_status);
+               }
+
+               wbc_status = WBC_ERR_AUTH_ERROR;
+               BAIL_ON_WBC_ERROR(wbc_status);
+       }
+       BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+       return wbc_status;
+}