std::string client::GetCdcState() { CDC_DC_STATE cdcState = CDC_DC_STATE_UNDEFINED; DWORD dwError = 0; std::string result; //This code would eventually move out of here //when other APIs become remotable PVMAFD_SERVER pServer = NULL; dwError = VmAfdOpenServerA(NULL,NULL,NULL,&pServer); BAIL_ON_ERROR(dwError); dwError = CdcGetCurrentState(pServer, &cdcState); BAIL_ON_ERROR(dwError); switch (cdcState) { case CDC_DC_STATE_NO_DC_LIST: result.assign("NO_DC_LIST"); break; case CDC_DC_STATE_SITE_AFFINITIZED: result.assign("SITE_AFFINITIZED"); break; case CDC_DC_STATE_OFF_SITE: result.assign("OFF_SITE"); break; case CDC_DC_STATE_NO_DCS_ALIVE: result.assign("NO_DCS_ALIVE"); break; case CDC_DC_STATE_LEGACY: result.assign("DISABLED"); break; default: result.assign("UNKNOWN"); break; } cleanup: if (pServer) { VmAfdCloseServer(pServer); } return result; error: THROW_IF_NEEDED(dwError); goto cleanup; }
JNIEXPORT jint JNICALL Java_com_vmware_identity_cdc_CdcAdapter_CdcGetCurrentState( JNIEnv *env, jclass clazz, jobject jpServer, jobject pState ) { DWORD dwError = 0; PVMAFD_SERVER pServer = NULL; CDC_DC_STATE cdcState = CDC_DC_STATE_UNDEFINED; if (jpServer == NULL) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_ERROR(dwError); } dwError = JniGetPointer(env, jpServer, (PVOID*)&pServer); BAIL_ON_ERROR(dwError); if (pState == NULL) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_ERROR(dwError); } dwError = CdcGetCurrentState( pServer, &cdcState ); BAIL_ON_ERROR(dwError); dwError = JniSetDword(env, pState, (DWORD)cdcState ,"number" ); BAIL_ON_ERROR(dwError); cleanup: return dwError; error: goto cleanup; }