Solved

Windows Authentication from Power Builder

Posted on 2007-04-04
9
1,993 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

856 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