Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titleOpen EDMdatabase
if (rstat = edmiOpenDatabase(dbPath, dbName, dbPwd)) {
  printf("\nERROR: Failed to open database with error '%s'", edmiGetErrorText(rstat));
  goto err;
}

The EDMdatabaseis EDMdatabase is now open and therefore uavailable to other EDMclient applications. At this stage, you would be connected to the database with a session for the default EDMuser named sdai-user. If we were to continue with API calls from here, it would be as the sdai-user. But in this sample, we will start by creating a new EDMuser and an EDMgroup. Only the superuser has permission to create new EDMusers and EDMgroups, so we now now need to connect as the superuser.

Code Block
languagecpp
titleConnect as superuser
if (rstat = edmiConnect("superuser", NULL, dbPwd, &unavailMess)) {
  printf("\nERROR: Failed to connect as superuser with error '%s'", edmiGetErrorText(rstat));
  goto err;
}

The password of the superuser is by default set to the password you specified when you created the EDMdatabase. If, from some reason, the EDMdatabase should be set temporarily unavailable by the susperuser, an attempt to connect would fail with the error code edmiEUNAVAILABLE. The message provided by the superuser will be returned in the unavailMess string. Next step will be to open a session for the superuser.

Code Block
languagecpp
titleOpen a session
if ((suSessId = sdaiOpenSession()) == 0) {
  printf("\nERROR: Failed to open session for superuser with error '%s'", edmiGetErrorText(rstat));
  goto err;
}