Solved

Windows Authentication from Power Builder

Posted on 2007-04-04
9
2,043 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…

623 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