/* * get certs * return cert array */ DWORD VmDirRESTGetRootCerts( void* pIn, void** ppOut ) { DWORD dwError = 0; PVDIR_REST_OPERATION pRestOp = NULL; PSTR pszCACNFilter = NULL; BOOLEAN bDetail = FALSE; PVMDIR_CA_CERT_ARRAY pCerts = NULL; json_t* pjCerts = NULL; PCSTR pszBaseDN = NULL; if (!pIn) { dwError = VMDIR_ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } pRestOp = (PVDIR_REST_OPERATION)pIn; dwError = VmDirRESTGetStrParam( pRestOp, "ca_cn_filter", &pszCACNFilter, FALSE); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirRESTGetBoolParam( pRestOp, "detail", &bDetail, FALSE); BAIL_ON_VMDIR_ERROR(dwError); pszBaseDN = VmDirSearchDomainDN(pRestOp->pConn->AccessInfo.pszNormBindedDn); if (IsNullOrEmptyString(pszBaseDN)) { BAIL_WITH_VMDIR_ERROR(dwError, VMDIR_ERROR_INVALID_PARAMETER); } dwError = VmDirGetCACerts( pRestOp->pConn, pszBaseDN, pszCACNFilter, bDetail, &pCerts); BAIL_ON_VMDIR_ERROR(dwError); dwError = _VmDirGetCertsJson(pCerts, bDetail, &pjCerts); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirRESTResultSetObjData( pRestOp->pResult, "certs", pjCerts); BAIL_ON_VMDIR_ERROR(dwError); cleanup: VmDirFreeCACertArray(pCerts); VMDIR_SET_REST_RESULT(pRestOp, NULL, dwError, NULL); VMDIR_SAFE_FREE_MEMORY(pszCACNFilter); return dwError; error: VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError); if (pjCerts) { json_decref(pjCerts); } goto cleanup; }
DWORD VmDirRESTObjectDelete( void* pIn, void** ppOut ) { DWORD dwError = 0; PSTR pszTenant = NULL; PSTR pszDN = NULL; BOOLEAN bRecursive = FALSE; PVDIR_REST_OPERATION pRestOp = NULL; PVDIR_OPERATION pDeleteOp = NULL; if (!pIn) { dwError = VMDIR_ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } pRestOp = (PVDIR_REST_OPERATION)pIn; dwError = VmDirRESTGetBoolParam(pRestOp, "recursive", &bRecursive, FALSE); BAIL_ON_VMDIR_ERROR(dwError); // TODO implement recursive option dwError = bRecursive ? VMDIR_ERROR_UNWILLING_TO_PERFORM : 0; BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirExternalOperationCreate( NULL, -1, LDAP_REQ_DELETE, pRestOp->pConn, &pDeleteOp); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirRESTGetObjectTenantParam(pRestOp, &pszTenant); BAIL_ON_VMDIR_ERROR(dwError) dwError = VmDirRESTDecodeObjectPathToDN( pRestOp->pszSubPath, pszTenant, &pszDN); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirStringToBervalContent(pszDN, &pDeleteOp->reqDn); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirStringToBervalContent(pszDN, &pDeleteOp->request.deleteReq.dn); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirMLDelete(pDeleteOp); BAIL_ON_VMDIR_ERROR(dwError); cleanup: VMDIR_SET_REST_RESULT(pRestOp, pDeleteOp, dwError, NULL); VMDIR_SAFE_FREE_MEMORY(pszTenant); VMDIR_SAFE_FREE_MEMORY(pszDN); VmDirFreeOperation(pDeleteOp); return dwError; error: VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError); goto cleanup; }
/* * refresh account password * returns: * if force is not specified and password is not aged * {"refreshed":"false"} * if force was specified or password aged * {"refreshed":"true","password":"******"} */ DWORD VmDirRESTRefreshPassword( void* pIn, void** ppOut ) { DWORD dwError = 0; PVDIR_REST_OPERATION pRestOp = NULL; BOOLEAN bRefreshPassword = FALSE; PSTR pszNewPassword = NULL; BOOLEAN bRefreshed = FALSE; if (!pIn) { dwError = VMDIR_ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } pRestOp = (PVDIR_REST_OPERATION)pIn; dwError = VmDirRESTGetBoolParam( pRestOp, "force", &bRefreshPassword, TRUE); BAIL_ON_VMDIR_ERROR(dwError) dwError = VmDirRefreshPassword( pRestOp->pConn, bRefreshPassword, &pszNewPassword); BAIL_ON_VMDIR_ERROR(dwError); VMDIR_LOG_DEBUG( VMDIR_LOG_MASK_ALL, "%s: force: %d, %s", __FUNCTION__, bRefreshPassword, pRestOp->pConn->AccessInfo.pszNormBindedDn); if (!IsNullOrEmptyString(pszNewPassword)) { bRefreshed = TRUE; dwError = VmDirRESTResultSetStrData( pRestOp->pResult, "password", pszNewPassword); BAIL_ON_VMDIR_ERROR(dwError); } dwError = VmDirRESTResultSetBooleanData( pRestOp->pResult, "refreshed", bRefreshed); BAIL_ON_VMDIR_ERROR(dwError); cleanup: VMDIR_SET_REST_RESULT(pRestOp, NULL, dwError, NULL); VMDIR_SAFE_FREE_MEMORY(pszNewPassword); return dwError; error: VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError); goto cleanup; }