on 07-08-2015 6:54 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
Hi David;
Have you read this section in the PB documentation yet?
HTH
Regards ... Chris
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.