cancel
Showing results for 
Search instead for 
Did you mean: 

how to check currentUserHasAccess in portal from webdynpro java

Former Member
0 Kudos

HI all,

I am working on Usermanagent and security APIs, in one menthod i want to check whether current user has access to portal from webdynpro java, for this i wrote below code,

public boolean currentUserHasAccess( java.lang.String userId ) {

//@@begin currentUserHasAccess()

boolean result = false;

IWDMessageManager manager = wdComponentAPI.getMessageManager();

// // get webdynpro user

String Str = "";

String UniqueStr = "";

try{

if(userId != null && !userId.equalsIgnoreCase(""))

{

IUser usr = UMFactory.getUserFactory().getUserByUniqueName(userId);

Str = Str + "\n" + usr.getDisplayName();

UniqueStr = UniqueStr + "\n" + usr.getUniqueID();

if(usr != null && UniqueStr != null)

{

result = true;

}

}

}

catch(UMException e1)

{

wdComponentAPI.getMessageManager().reportException(e1.getMessage(),false);

}

return result;

//@@end

}

but it is throwing exception when user doesnt exist in portal, so would you please suggest where i went wrong.

and also i wnated to know how to get time and date of loggedin user ( i just want to keep the track of this login user time like how mush time he loggedin and how much time he spent time on this page etc)

thanks in advance

Anusha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anusha,

Please find the below code

//Fetching Current logged user

try

{

IWDClientUser clientUser = WDClientUser.getCurrentUser();

IUser user = clientUser.getSAPUser();

wdContext.currentContextElement().setName("Welcome, "+user.getDisplayName());

}

catch (WDUMException e)

{

wdComponentAPI.getMessageManager().reportException(

e.getMessage(), false);

}

Former Member
0 Kudos

HI rahul,

This is i already implemented, i want to check whether loggedin user exists in portal or not / current user has access to portal , i have done it thanq

Anusha

vijay_kumar49
Active Contributor
0 Kudos

Hi Anusha,

Please check it. Print the Username while its coming or not. and check it any Exceptrion u r getting

Regards

Vijay K

Answers (1)

Answers (1)

vijay_kumar49
Active Contributor
0 Kudos

Hi Anusha,

Please look at this wiki :

[User & Role Based Access Into a Web Dynpro Project|http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=16442] and [Check all Users who have logged into portal u2013WDJ|http://wiki.sdn.sap.com/wiki/display/WDJava/CheckallUserswhohaveloggedintoportal-webdynproappl]

Hope this helps!!

Regards

Vijay K

Former Member
0 Kudos

Hi vijay,

thanks for the reply

I tried that but it didnt work for me, if i get users list from portal then i can able to do it, but i couldnt able to get the users i tried groups it is working fine, but users are not workig

thanks

anu