cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a user via UME

cand1
Advisor
Advisor
0 Kudos

Hi everybody,

I've created a user with the following lines:

String testUserId = "User0815";

IUserMaint user = userFactory.newUser(testUserId);

user.setFirstName("firstname");

user.setLastName("lastname");

user.setEmail("first.last@test.de");

user.commit();

IUserAccount userAccount = userAccountFactory.newUserAccount(testUserId, user.getUniqueID());

userAccount.setPassword("secret");

userAccount.setPasswordChangeRequired(false);

userAccount.save();

userAccount.commit();

This works fine, but afterwards I want to the delete the user and the according account with

IUser userToDelete = userFactory.getUserByLogonID(testDUserId);

userFactory.deleteUser(userToDelete.getUniqueID());

The second call to

IUserMaint user = userFactory.newUser(testUserId);

gives me a com.sap.security.api.UserAlreadyExistsException, i.e. it seems the user was not deleted. So my question is, what's the right way to delete an user?

Best Regards,

Daniel

View Entire Topic
Former Member
0 Kudos

Hi,

What is your data source? Check whether the userid actually present there? Were any exceptions raised? Put a print in the catch statement and see if there is any error.

The code you have given seems to be correct, except that I did it as below and it worked. Try this way.

IUser user=uf.getUserByUniqueName(strUserID);

String strUniqueUserID=user.getUniqueID();

uf.deleteUser(strUniqueUserID);

Good luck

Bhanu

cand1
Advisor
Advisor
0 Kudos

Hi Bhanu,

IUser userToDelete = userFactory.getUserByUniqueName(testDUserId);

was the key.

BTW: The difference between getUserByUniqueName() and getUserByLogonID() is not clear to me, but never mind, it works.

Thanks,

Daniel

Former Member
0 Kudos

To view the difference in EP6:

User Admin -> Roles -> do a search on the userid -> edit

you will see the unique id differs quite a bit from the user id. Same for roles etc...