Solved

Windows Authentication from Power Builder

Posted on 2007-04-04
9
1,972 Views
Last Modified: 2012-02-03
OS : WINDOWS XP
SOFTWARE : POWERBUILDER

I want to use the windows authentication to logon with my application.  I am using LOGONUSERA Windows Function

The Global External Function declaretion is
Function Integer LogonUserA(String lpszUsername,String lpszDomain,String lpszPassword,integer dwLogonType,Integer dwLogonProvider,REF long phToken) Library "advapi32.dll"

// The following variables are global Variable

long LOGON32_LOGON_INTERACTIVE= 2
long LOGON32_LOGON_NETWORK= 3
long LOGON32_PROVIDER_DEFAULT= 0
long LOGON32_PROVIDER_WINNT50= 3
long LOGON32_PROVIDER_WINNT40= 2
long LOGON32_PROVIDER_WINNT35= 1

// command button clicked event
LogonUserA(username,password,domainname,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,token)

if li_ret = 0 then
messagebox("","login failed")
else
messagebox("","logon success")
end if

The above code is working with my LoginName and Password. If i try other Person's LoginName and Password is not working. Can you pelase find out what could be the reason ?
0
Comment
Question by:abcexpert
  • 3
  • 2
9 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 18850656
First, I'll presume you did
li_ret=LogonUser...

and that '=' is a valid assignment operator.

Given that, what does GetLastError() give you?
0
 

Author Comment

by:abcexpert
ID: 18855925
li_ret = LogonUserA(username,password,domainname,LOGON32_LOGON_NETWORK,LOGON32_PROVIDER_DEFAULT,token)

if li_ret = 0 then
messagebox("","login failed")
else
messagebox("","logon success")
end if

Yes it is a valid assignment operator

GetLastError() is a Windows function ?
0
 
LVL 22

Expert Comment

by:cookre
ID: 18856813
Yes.  Since many API functions return something other than a status code, the status code is made available via a call to GetLastError().

A list of system error codes is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:abcexpert
ID: 18857472
GET LAST ERROR() is retrun the following error
ERROR_LOGON_TYPE_NOT_GRANTED
1385 Logon failure: the user has not been granted the requested logon type at this computer.

I added the other user name on my pc, now i can able to logon with the other user name.

Is there any way to avoid this step ?  
I want to achieve all the domain users can access my application from any pc  ?
Thanks for your reply
0
 
LVL 22

Accepted Solution

by:
cookre earned 500 total points
ID: 18861099
If everyone is in the same domain, then just set the appropriate permissions for some group, possibly Everybody, then they get access by virtue of their own domain logon.

Of course, you could turn your box in to a Terminal Services box, but that involves, erm, a slight extra cost.
0
 

Expert Comment

by:qwerty33
ID: 37535957
after i tried the coding above, the GetLastError() return code is 126, which mean to the module could be not found no matter i using my own login id or others. so may i know what is happening and how to solve it? although i had paste the dll file into the folder that stored my application.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question