cancel
Showing results for 
Search instead for 
Did you mean: 

Passing the user ID from portal to the backend and update it in the table

Former Member
0 Kudos

Hi Experts

In my portal application i need to pass the username of the person who is logged in and pass the same from the portal code to the backend and update it in the table.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos
IWDClientUser wdclientuser = WDClientUser.getCurrentUser();
                        if (wdclientuser != null) {

                                com.sap.security.api.IUser iUser = wdclientuser.getSAPUser();
                                if (iUser != null) {

                                        IUserAccount[] accounts = iUser.getUserAccounts();
                                        if (accounts[0] != null) {

                                                userID = accounts[0].getLogonUid();

                                        }
                                }

                        }

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks to all. My query has been resolved.

Former Member
0 Kudos

Hi Rizwana,

i have the similar issue to, how your problem got solved send me do u refered any document or pdf.

it will be useful me in solving the issue

my issue is

when ever a portal user logs in, it should validate the user to which region it belongs to and we have external user and internal user by checking in the table, table contains the filelds user, region,client ...

Thanks in advance

Thanks&Regards

charan

Former Member
0 Kudos

Using this piece of code i get the login ID of the user who is currently logged in but i also want it to be updated in the backend table. I have created a value attribute for the same and i am setting the same in the custom controller using its setter method but after this it is throwing an "array out of bound exception -1" although i have added an extra parameter for the execute method in the custom controller. I have also done the model binding for this custom controller value attribute.

former_member185879
Active Contributor
0 Kudos

Hello Rizwana,

After getting the portal login, you assign this to the String attribute or variable and send it to the RFC.

Regards

Nizamudeen SM

0 Kudos

Hi Rizwana,

you can set the userid to RFC input attribute throw following way.

Map RFC node from component controller to view and set the value to particular RFC attribue by using the setter method of attribute if ur writing the code to getting userid in VIew. see the following example code.

if (accounts[0] != null)

{

userID = accounts[0].getLogonUid();

wdContext.current<RFCNodeName>Element.set<AttributeName>(userID);

}

if you are writing the code to getting userid in component controller declare the userID variable in begin others section and set the RFC input attribute by using setter method before the modelobject().ececute() line of code.

wdContext.current<RFCNodeName>Element.set<AttributeName>(userID);

Revert back if you have any queries.

Thanks & Regards,

Bhargava.

junwu
Active Contributor
0 Kudos

what you are trying to do ?

can you make it more clear?

update it in table? what is it?

former_member185879
Active Contributor
0 Kudos

IWDClientUser clientUser = WDClientUser.getCurrentUser();

IUser User = clientUser.getSAPUser();

if (User != null)

{

try

{

IUserAccount[] acct = User.getUserAccounts();

if(acct[0] != null)

{

userID = acct[0].getLogonUid();

}

}

catch(UMException e)

{

//Raise some error msg according to your scenario.

}

}

Also try to make this as a common method and call this whenever you required, so that in future projects also you dont want to write the same code again and again.

Revert for any queries.

Regards

Nizamudeen SM