cancel
Showing results for 
Search instead for 
Did you mean: 

PowerBuilder 11.5 & LDAP authentication (Active Directory)

Former Member
0 Kudos

I working on a Client Application developed with PowerBuilder 11.5.

Before entering in the application, a login and a password
is asked. I would like to authenticate the application with LDAP.
(Active Directory).

Is there a link to any .zip file or any PowerBuilder Libraries and dll files that I can download from for this LDAP authentication?

Do I need to have Java virtual machine for this LDAP authentication?

Can you please help me on this?

Thanks you very much in advance.

0 Kudos

Hello do you managed to create an application using ldap login? Please help me

AlexGourdet
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Avaa,

We're glad to have you in the community looking for answers to your questions, but you posted a question as an answer (which I converted to a comment) in a thread which is a few years old by inactive thread (with former members) from 2015.

I want you to get the help you need, but you're unlikely to get any responses this way. Therefore, I'd like to offer some friendly advice:

* Try asking a new question instead at https://answers.sap.com/questions/ask.html.

* Familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

* Take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html, as that will also help you when preparing questions for the community.

* Complete your profile by following the steps at https://developers.sap.com/tutorials/community-profile.html, as a complete profile encourages readers to respond.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the Best,
-Alex

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Chris & Shenn:

Thank you both very much for your response.

I actually have the following code for the Trust based authentication:

this is powerbuilder code

Global Variables
String gs_user_gmk_id, gs_username, gs_gmid, gs_id_num

Global External Functions
FUNCTION boolean GetUserNameA(ref string uname, ref ulong slength) LIBRARY

"ADVAPI32.DLL" alias for "GetUserNameA;Ansi"

w_logo
open event

ulong lu_val
boolean lb_rtn
lu_val = 255
gs_username = Space( 255 )
lb_rtn = GetUserNameA(gs_username, lu_val)
gs_username = trim(gs_username)
gs_gmid = gs_username

I would like to know if there is authentication based on using Java file to go to the Active Directory and do the actual authentication NOT (Single sign on).

How can I call a Java file (function) which does the Authentication.  So, I want to invoke the Java function from the PowerBuilder 11.5.

Thanks & Best Regards,

-David

Former Member
0 Kudos

Hi David;

  Yes, you could call a Java class to broker the AD interaction for your PB application. You could accomplish this by ...

1) Calling a Java based web service via SOAP.

- OR -

2) Instantiating a Java class directly from PB. Have a look at:

   a: JavaVM

   b: createJavaInstance

HTH

Regards ... Chris

Former Member
0 Kudos

Greetings Chris:

Thank you sir for your response.  I have created a very basic Java program (Hello World).  I need to call this little program from my PowerBuilder Application.  What code do I need to put in my PowerBuilder application in order to invoke my Java "HelloWorld.java"?

Here is my Java Hello WOrld source code:

public class HelloWorld {

   public static void main(String[] args) {

      System.out.println("Hello, World");

   }

}

Thanks for all your efforts and support sir.

Kind Regards,

-David

Former Member
0 Kudos

Hi David;

  Have you read this section in the PB documentation yet?

http://infocenter.sybase.com/archive/index.jsp?topic=/com.sybase.dc37794_1150/html/pbnigref/BJEJDACJ...

HTH

Regards ... Chris

Former Member
0 Kudos

Hello Chris:

I went to the link that you provided.  I typed in the following code:

In the open event of a window, create a Java VM:

// instance variable: javavm i_jvm

string properties[]

i_jvm = create javavm

string classpath

i_jvm.createjavavm(classpath, propertie

I got the following warning and error messages for (i_jvm = create javavm) line above:

Warning:  C0014:  Undefined variable:  i_jvm

Error:  C0047:  Simple datatype illegal for create statement:  javavm

Best Regards,

-David

Former Member
0 Kudos

Hi David;

  You will need to add the "pbejbclient115.pbd" library to your PB Target's library list.  

Regards ... Chris

Former Member
0 Kudos

Hi Chris,

I managed to get the windows user id using the function GetUserNameA in ADVAPI32.DLL.  But my problem is to get the AD group tied up to the userid.  Is there any dll/function already available just like GetUserNameA?  When we tried looking for this earlier last year, we can't find any solution so what we did is create a dll from .net and use it as external function in PB.  It is working fine. But the problem is, my client don't want to use a .net source and wanted to use whatever is available in PowerBuilder.

Hope you can give details on this.

Thanks so much.

Regards,

Elena

Former Member
0 Kudos

Hi Elena;

1) Since PB v10.0 and higher is Unicode - you should use the GetUserNameW API call instead.

2) You need to use the ADSI (Active Directory Service Interface) API's instead to get the User ID's, AD signature. Once you have that, you can call the AD server to validate their login privileges, inclusion in groups, etc.

Regards ... Chris

Former Member
0 Kudos

Declare these Local External Functions...


Function ulong WNetGetUser(string lpname, ref string lpusername, ref ulong buflen) Library "mpr.dll" Alias For "WNetGetUserW"

Function boolean LogonUser ( string lpszUsername, string lpszDomain, string lpszPassword, ulong dwLogonType, ulong dwLogonProvider, ref ulong phToken) Library "advapi32.dll" Alias For "LogonUserW"

Function boolean CloseHandle (ulong hObject) Library "kernel32.dll"

I built a basic window to do the authentication...

Here is the code for the OK button...


Constant ULong LOGON32_LOGON_NETWORK = 3

Constant ULong LOGON32_PROVIDER_DEFAULT = 0

String ls_domain, ls_user, ls_password

ULong lul_token

Boolean lbl_result

//Sets & Gets values

ls_domain = ""

ls_user = Trim(sle_user.text)

ls_password = Trim(sle_password.text)

//Error checking

if (isNull(ls_user) OR ls_user = "") then

    MessageBox("LOGIN ERROR", "You must enter a User ID.", StopSign!)

    sle_user.SetFocus()

    return

end if

//Error checking

if (isNull(ls_password) OR ls_password = "") then

    MessageBox("LOGIN ERROR", "You must enter a Password.", StopSign!)

    sle_password.SetFocus()

    return

end if

SetPointer(HourGlass!)

//Determines is the User ID & Password are valid

lbl_result = LogonUser( ls_user, ls_domain, ls_password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, lul_token )

//Valid

If (lbl_result) Then

   

    //Close Handle of Token

    CloseHandle(lul_token)

   

    //Changes status

    ibl_nogood = false

   

    //Closes with the User ID

    CloseWithReturn(parent, ls_user)

   

Else

   

    //Error Message

    MessageBox("LOGIN ERROR", "Invalid User ID or Password.", StopSign!)

   

End If

Former Member
0 Kudos

Hi Shenn;

That is a great example of an MS-Windows login validation!

However, that is not Active Directory. Instead, you would use the ADSI (Active Directory Service Interface) API's instead.

Regards ... Chris

former_member224626
Discoverer
0 Kudos

Hey Chris,

This can be turned into AD authentication by passing the Domain value to LogonUser() function (as per Roland Smith) - it would authenticate against the AD on the Domain Controller; otherwise (with an empty Domain value), it would authenticate a local account. We can query the value of the Domain using OLE from ADSystemInfo.DomainDNSName or WScript.Network.UserDomain.

Regards,

Shekar Reddy
PowerObject!

Former Member
0 Kudos

HI David;

  Have a look at my Active Directory (LDAP) Web Service built in PB Classic. You can just deploy this and then call it from your PB Client application. It provides user, group & role authentication.

STD Foundation Classes - Browse /Applications/WebService/LDAP at SourceForge.net

  I did a presentation on Active Directory at the 2015 PB Conference last May. Let me know if you would like to look at the presentation slides.

Regards ... Chris