Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
Deletes an EDMuser identified by its name 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.
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteDeleteUserBN(SdaiServerContext serverContextId,
                                  SdaiString        userName, 
                                  SdaiInvocationId  *edmiInvocationId); 
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

userName

The name of 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;
 
/* Define Remote Server Context
for the superuser */ 
rstat = edmiDefineServerContext("SuperUserContext",
"superuser", NULL, "xfx56kl9",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &suContext); 
 
/* Try to delete 'Lucy' */
rstat = edmiRemoteDeleteUserBN(suContext, "Lucy", 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; 
SdaiUser _lucyUserId, _johnnyUserId; 
 
/* Get the 'Lucy' user Id */ 
rstat = edmiRemoteGetUser(suContext, "Lucy", &_lucyUserId, NULL); 
 
/* 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"); 
}
. . .

  • No labels