Deletes an EDMuser identified by its userId from a remote EDMdatabase.
An EDMuser may not be deleted when it is connected to an EDMserver. Neither may it be deleted if it is the owner of data in the remote EDMdatabase.
Only the superuser may use this function.
Related functions: edmiRemoteCreateUser, edmiRemoteDeleteUserBN, edmiRemoteGetUser.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteDeleteUser(SdaiServerContext serverContextId,
SdaiUser userId,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
userId |
The numeric userID that uniquely identifies the EDMuser to be deleted. |
edmiInvocationId |
Currently not used. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
/* Delete User 'Lucy' and Give
all Lucys objects to Johnny. */
EdmiError rstat;
SdaiServerContext suContext;
SdaiUser lucyUserId, johnnyUserId;
/* Define Remote Server Context
for the superuser */
rstat = edmiDefineServerContext("SuperUserContext",
"superuser", NULL, "xfx56kl9",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &suContext);
/* Get the user Id for 'Lucy' */
rstat = edmiRemoteGetUser(suContext, "Lucy", &lucyUserId, NULL);
/* Try to delete 'Lucy' */
rstat = edmiRemoteDeleteUser(suContext, lucyUserId, NULL);
if (rstat == edmiE_USER_OWNS) {
/* Lucy may not own objects when deleted.
Must locate an object owned by Lucy. */
SdaiAggr _instAggr;
SdaiModel _instId;
SdaiInteger _index, _nInst, _nTot;
/* Get all edm_models from the ExpressDataManager model */
rstat = edmiRemoteGetEntityExtentBN(suContext, "SystemRepository",
"ExpressDataManager", "EDM_MODEL", 0,
&_instAggr, &_nInst, &_nTot, NULL);
_index = 0;
_nInst = 1;
_instId = 0;
/* Look for models owned by 'Lucy' */
rstat = edmiRemoteFindAggrInstances(suContext, _instAggr,
"OWNER = lucyUserId", 1,
&_index, &_nInst, &_instId, NULL);
if (!_instId) {
/* Lucy owns no models. Get all edm_repositories
from the ExpressDataManager model */
rstat = edmiRemoteGetEntityExtentBN(suContext, "SystemRepository",
"ExpressDataManager", "EDM_REPOSITORY", 0,
&_instAggr, &_nInst, &_nTot, NULL);
_nInst = 1;
/* Look for repositories owned by 'Lucy' */
rstat = edmiRemoteFindAggrInstances(suContext, _instAggr,
"OWNER = lucyUserId", 1,
&_index, &_nInst, &_instId, NULL);
if (!_instId) {
/* Lucy owns no protected objects. Something is wrong.
There is nothing more to be owned by Lucy !! */
printf("ERROR: Can not find object owned by Lucy");
goto err;
}
}
/* Get the 'Johnny' user Id */
rstat = edmiRemoteGetUser(suContext, "Johnny", &johnnyUserId, NULL);
/* Give all objects owned by Lucy to Johnny */
rstat = edmiRemoteChangeInstanceOwner(suContext, _instId,
johnnyUserId, FOR_ALL_OWNED_INSTANCES, NULL);
/* Delete Lucy */
rstat = edmiRemoteDeleteUser(suContext, lucyUserId, NULL);
printf("\nLucy was deleted. Johnny was given ownership \
to all Lucys objects");
}
. . .