libwbclient: Use wbcCtxSidsToUnixIds in wbcCtxSidToUid
authorVolker Lendecke <vl@samba.org>
Tue, 9 Feb 2016 06:36:13 +0000 (07:36 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 22 Feb 2016 19:29:15 +0000 (20:29 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
nsswitch/libwbclient/wbc_idmap.c

index cc5fce6e1f83dc4d2bd295ffee44e15325315b5f..6735d3d3e9ee652570394a6ab36a82562ea58a0a 100644 (file)
 wbcErr wbcCtxSidToUid(struct wbcContext *ctx, const struct wbcDomainSid *sid,
                      uid_t *puid)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
-       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       struct wbcUnixId xid;
+       wbcErr wbc_status;
 
        if (!sid || !puid) {
                wbc_status = WBC_ERR_INVALID_PARAM;
                BAIL_ON_WBC_ERROR(wbc_status);
        }
 
-       /* Initialize request */
-
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
-       wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));
-
-       /* Make request */
-
-       wbc_status = wbcRequestResponse(ctx, WINBINDD_SID_TO_UID,
-                                       &request,
-                                       &response);
-       BAIL_ON_WBC_ERROR(wbc_status);
-
-       *puid = response.data.uid;
+       wbc_status = wbcCtxSidsToUnixIds(ctx, sid, 1, &xid);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
+               goto done;
+       }
 
-       wbc_status = WBC_ERR_SUCCESS;
+       if ((xid.type == WBC_ID_TYPE_UID) || (xid.type == WBC_ID_TYPE_BOTH)) {
+               *puid = xid.id.uid;
+               wbc_status = WBC_ERR_SUCCESS;
+       } else {
+               wbc_status = WBC_ERR_DOMAIN_NOT_FOUND;
+       }
 
  done:
        return wbc_status;