cancel
Showing results for 
Search instead for 
Did you mean: 

com.sap.security.api.NoSuchUserException

Former Member
0 Kudos

Hi All,

I am using UserManagement API to retriev user info

I used the foloowing line of code.


IUserFactory userFactory= UMFactory.getUserFactory();
IUser myUser = userFactory.getUser(request.getUser().getUserId());

It is at this line,it throws an Exception

<b>com.sap.security.api.NoSuchUserException</b>.

I did not understand the reason.

Can any one help me in this regard.

Regards,

Santhosh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Your code has one small error in it. Replace the following


IUser myUser = userFactory.getUser(request.getUser().getUserId());

to

IUser myUser = UMFactory.getUserFactory().getUserByLogonID(request.getUser().getUniqueName());

You could also do this which will get you user object from which you could get any information.

IUser myUser = request.getUser();

Former Member
0 Kudos

Hi Prakash,

Thanks for the reply..

In ur code

IUser myUser = UMFactory.getUserFactory().getUserByLogonID(request.getUser().getUniqueName());

The method request.getUser() returns IUserContext interface..And I didn't find the method getUniqueName()

in IUserContext.

Can you help me regarding the same..

Thanks in Advance.

Santhosh

Former Member
0 Kudos

Hi Santhosh,

IUserContext is same as IUser. Just cut & paste the code it should work.

IUser myUser = UMFactory.getUserFactory().getUserByLogonID(request.getUser().getUniqueName());

you could also try the following code to get the current user.

IUser myUser = request.getUser();

What is the version of your portal?

PS: Please reward points for helpful answer or problem resolved.

Former Member
0 Kudos

Hi Prakash,

As I already said the following line

IUser myUser = request.getUser();

is giving compilation error(type mismatch can

not convert IUserContext to IUser) so I did explicit

type cast.That line I changed as below and is working

fine.

IUser myUser = (IUSer)request.getUser();

wat do u say Prakash,regarding this?

*You and Rajeev gave very helpful answers,I am awarding points accordingly.

Regards,

Santhosh

Former Member
0 Kudos

Hi Edla

Try out with the following code

IUser iuser=UMFactory.getUserFactory().getUserByUniqueName("xxx");//give user id here

IRole irole=UMFactory.getRoleFactory().getRoleByUniqueName("yyy");//give role name here

String useruid=iuser.getUniqueID();

String roleuid=irole.getUniqueID();

UMFactory.getRoleFactory().addUserToRole(useruid,roleuid);

Regards

Rajeev.