Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows Authentication from Power Builder

Posted on 2007-04-04
9
Medium Priority
?
2,069 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

688 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