cancel
Showing results for 
Search instead for 
Did you mean: 

how to check Username and Password

Former Member
0 Kudos

hai

in my application i'm navigating from Login page to Home Page . in login page i have to check for particular user name and password let us say abc and abc. if the user enters wrong username and password it should redirect to login page. is there any snippet of code

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Friends,

I installed SAP NW2004s and i assign the username as "SAPUSER" as by default and password as "india123" but when i try to login then it gives me error as invalid name or password.

Please any 1 can suggest me how can i check which is right username and password for login or suggest me by default administration login.

Thanks,

Lalit

Former Member
0 Kudos

Do you use WebAS default authentication?

If yes check if the user and the password are correct in the UME of the WebAS.

Former Member
0 Kudos

Hi,

Thanks for reply. I am trying to login through frontend. and also i want to create user and client which can access "RSA1" access code. Any 1 can suggest me how can i do this.

Lalit

Former Member
0 Kudos

Hi Sravan

I suppose the two pages you have mentioned are two views in your WebDynpro component.

If so,the snippet of code that serves your purpose is given below. It is assumed that you have bound your input fields for username and password to corresponding value attributes in the view context(say userid and pswd). The code should be written in the onActionEvent of your Submit button.

String username=wdContext.currentContextElement.getUserid();

String password=wdContext.currentContextElement.getPswd();

if(username.equals("abc")&&password.equals("abc"))

{

wdThis.wdFirePlugToHome();

}

else

{

wdComponentAPI.getMessageManager().reportSuccess("Invalid Login");

}

Regards

Leena

Former Member
0 Kudos

Hi Sravan,

Import this package in your login view

com.sap.tc.webdynpro.progmodel.controller.MessageManager;

And if your context attributes are Name and Password.And if you are navigating from LoginView to HomeView. Write the code given below inside your action event.

String login=wdContext.currentContextElement().getName();

String password=wdContext.currentContextElement().getPassword();

if(login!=null && login.equalsIgnoreCase("XXX") && password!=null && password.equalsIgnoreCase("YYY"))

{

wdThis.wdFirePlugToHomeView();

}

else

{

MessageManager msgMgr= (MessageManager) wdThis.wdGetAPI().getComponent().getMessageManager();

msgMgr.reportException("Login failure.Pls check login details",true);

}

Hope this will help you

Regards,

Rajeev

Former Member
0 Kudos

Thanks Leena Ramachandran n Rajeev Ranjan

Former Member
0 Kudos

Hi

It would be advisable to check for Username and password using the way how Jens had suggested. You can configure the UME to create the Users. Here is a link that explains about User Management Engine.

http://help.sap.com/saphelp_nw04/helpdata/en/e5/618a3eacd49076e10000000a114084/frameset.htm

Using a UME would be more standard and easy in this case.

Hope that was helpful.

regards

ravi

Former Member
0 Kudos

Hi Sravan,

Just use WebAS default mechanism to protect your application.

Go to Web Dynpro -> Applications -> <your Application> -> edit

open tab "Application properties" and set "sap.authentication" to "true"

If you want to change this login page it is a little bit more complicated but possible.

regards

Jens

Former Member
0 Kudos

hi, Jens Rothweiler

i will be more precise

i have a form in my first view so i want to give only one username and passsword to navigate to second view for that where should i write the code

i think it should be written in wdModifyView

Former Member
0 Kudos

Hi Sravan

You could write that code onAction Event of your Submit Button of the login form .

If the user id and password is valid , fire the outbound plug to the next view , if not just so a message "Invalid Login" and do not fire any plugs , so that it stays in the same view.

Regards

Bhanu