cancel
Showing results for 
Search instead for 
Did you mean: 

How to authenticate the user through LDAP in SUP 2.2 without workflow

Former Member
0 Kudos

Hi,

I have an LDAP server with some user created.I tried creating the login screen in workflow(.xbw) for authenticating the user through LDAP server. and I was able to do the same succesfully.

But now i am using a different approach. I am creating my own HTML pages in Generate hybrid app folder which i have generated though generate Hybrid App API option. I want to implement the same functionality in my own javascript file though code.

Could you please let me know the way

1. How to write the authenticate functionality in JS files in generated hybrid app folder

                                                                OR

2. Can i call an HTML page available in generated hybrid app folder from the workflow screen. i.e If i create the login screen in workflow and on clicking the login can i navigate to HTML page. I tried writing window.location="path/file.html". Also i tried navigateForward in custom.js file but none of it is working.

I have done the following setups

1. Created the LDAP server in Apache directory studio.

2. Created a security configuration in SCC successfully- validated and applied

3. Assigned the Security configuration to default domain.

Accepted Solutions (0)

Answers (3)

Answers (3)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

It should be possible to create a login page similar to how the hybrid app designer does and be able to cache your credentials.  If I get a chance I will try it out.  I vaguely remember an issue with doing this so will attempt to follow up on that.

Another way would be to store the credentials into the secure local storage using SUPStorage.js and then before calling a method of the JavaScript API, get the user name and password from the storage.

Instead of hardcoding the user name and password as shown below,

department_findByPrimaryKey(dept, "supusername=supAdmin&suppassword=s3pAdmin", "onError");

retrieve them from the secure storage after you have stored them there.

storage = new hwc.SUPStorage();

storage.setItem("UserID", "supAdmin");

alert(storage.getItem("UserID");

Hope that helps,

Dan

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I was able to create an example using the credential storage feature provided by the HWC.  Note this only works for MBO based apps. 

In the packaging tool, be sure remove the username and password and provide a cache key.

Here is the code I used.

<html>

<head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

        <meta name="HandheldFriendly" content="True" />

        <meta http-equiv="PRAGMA" content="NO-CACHE" />

        <meta name="viewport" content="initial-scale = 1.0 ,maximum-scale = 1.0" />

        <script src="js/PlatformIdentification.js"></script>

        <script src="js/hwc-api.js"></script>

        <script src="js/hwc-comms.js"></script>

        <script src="js/hwc-utils.js"></script>

        <script src="js/WorkflowMessage.js"></script>

        <script src="js/HybridApp.js"></script>

        <script>

        alert(window.location.href);

       

        function setCreds() {

                  saveLoginCredentials("supAdmin", "s3pAdmin");

        }

       

        function findDept() {

                  var deptID = "100";

            var dept = new Department();

            dept.dept_id = deptID;

            //department_findByPrimaryKey(dept, "supusername=supAdmin&suppassword=s3pAdmin", "onError");

            department_findByPrimaryKey(dept, "", "onError");

        }

       

        hwc.processDataMessage = function (incomingDataMessageValue) {

            if (incomingDataMessageValue.indexOf("<M>") != 0) {

                alert("An error occurred!  " + incomingDataMessageValue);

            }

            var workflowMessage = new WorkflowMessage(incomingDataMessageValue);

            var messageValueCollection = workflowMessage.getValues();

            var deptName = messageValueCollection.getData("Department_dept_name_attribKey").getValue();

            alert("Department name is: " + hwc.trimSpaces(deptName));

        }

       

        </script>

</head>

<body>

    <button type="buton" id="setCreds" onclick="setCreds();">Set Creds</button><br>

    <button type="buton" id="findDept" onclick="findDept();">Find Dept</button><br>

    <button type="buton" id="close" onclick="hwc.close();">Close</button><br>

</body>

</html>

To try this out, create a Department MBO, generate a JavaScript MBO API, create an HTML file with the above content, package it up and deploy it.

First click on Find Dept and notice that the department name is not shown.  Click on the Set Creds and then click on Find Dept.  Then close the hybrid app and reopen it and notice that you can now click on Find Dept without the call to Set Creds as they are stored in the credentials cache.

former_member184221
Contributor
0 Kudos

Have a look at all the discussions that use Sencha within the HWC instead of jQueryMobile. These implementations need to authenticate and do this showing the base HWC methods.

This tutorial is worth a read http://scn.sap.com/docs/DOC-39893

Former Member
0 Kudos

Any updates