Solved

Windows Authentication from Power Builder

Posted on 2007-04-04
9
1,945 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Order table with macro 3 75
hasOne  challenge 59 92
array6 challenfge 6 65
allStar challenge 1 43
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now