cancel
Showing results for 
Search instead for 
Did you mean: 

geting User in Portal Service

0 Kudos

Hi,

my aim is to create web service form the portal service, I have to access the all pages navigational URL for particular Role. I have implemented already this logic in my Web Dynpro application but now I have to make web Service which is going to implement the same logic.

So what I am doing is I get the user as parameter then I check the Roles for user and then one by one I do lookup on uniqueRolename to get the IPcdContext then I pass the IPcdContext to another function which will then look for PagesURL.

Ok now before I use lookup I have to assign the user in Context environment I have done like this

InitialContext ic = new InitialContext(environment);

IUserFactory uf = UMFactory.getUserFactory();

IUser admin = uf.getUserByUniqueName("admin");

ic.addToEnvironment(Context.SECURITY_PRINCIPAL,admin);

But when it add admin in the enviorment it throws NamingException , I do not know what to do what this is there any other way?

Best Regards

Yasir Noman

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Yasir,

Change the

IUser admin = uf.getUserByUniqueName("admin"); 

to

IUser admin = uf.getUserByLogonID("admin");

pRAKASH

0 Kudos

Hi Parkash,

getUserByLogonID("admin") did not work either.

any other solution plz?

Regards

Yasir Noman

Former Member
0 Kudos

Hi Yasir,

getUserByLogonID should work. Check to see if you have a user with ID "admin".

Prakash

0 Kudos

Hi Parkash,

Well this thing is when I debug I see it retrieve the user Info but the time it when I add to Environment it makes problem So what I did add Initial_Context_Factory first then I add "Admin" to environment. But now the problem is coming when it reaches to last line it give me SOAPService error, I can see in debug that ic.lookup()returns the value but when it try to dipreciate it to IPcdContext it ask me in debug mode to reference the "Com.Sapportals.Portal.prt.Service.SOAP.Processor.SOAPPortalServicePro" could not find. I think I there should be different way to deal with IPcdContext in SOAP.

any idea regarding this?

InitialContext ic = new InitialContext(environment);

IUserFactory uf = UMFactory.getUserFactory();

IUser admin = uf.getUserByLogonUniqueName("admin");

ic.addToEnvironment(Context.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.pcd.gl.PcdInitialContextFactory");

ic.addToEnvironment(Context.SECURITY_PRINCIPAL,admin);

pcdCtx = (IPcdContext) ic.lookup(rolename);