LogonUser API help 
Author Message
 LogonUser API help

I am wondering if anyone could please send me an example of using the
LogonUser API call written in VB.

We are writting an application that needs to logon to the network and would
like to use this call.  I think our problem stems around the phToken that
must be passed.  Which we have no idea about.

Any help or examples would be greatly appreciated.

Thanks,

Jeff Levy




Sun, 30 May 1999 03:00:00 GMT  
 LogonUser API help

After seeing your post I decided to figure LogonUser out.  Here's what I
found:

First of all, the Declare in the API viewer is wrong in that LogonUser is a
function exported by ADVAPI32.DLL, not KERNEL32.DLL.  Next, when I was
finally able to call the function, initially it returned False.  After
checking the Win32 SDK documentation and knowledge base, I found out that
the calling process has to have certain privileges.  In other words, the
user or service that is calling the function must have the following
advanced user rights set up in the User Manager:

Privilege               Display Name (in User Manager, User Rights Policy)
----------------------------------------------------------------------------
-------------------------------------
SeTcbPrivilege          Act as part of the operating system
SeAssignPrimary Replace a process level token
SeIncreaseQuota Increase quotas

Having said all of that, here's an example on how to use LogonUser:

Dim bReturn As Boolean
Dim hToken As Long
Dim sUserName As String
Dim sPassword As String
Dim sDomain As String

sUserName = "some user name"
sPassword = "somepassword"
sDomain = "SOMEDOMAIN"

bReturn = LogonUser(sUserName, sDomain, sPassword,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken)
CloseHandle (hToken)

The phToken argument is a handle to the user that is logged on by
LogonUser.  You can use this token handle in calls to the
ImpersonateLoggedOnUser and CreateProcessAsUser functions.

Let me know how this works for you.
--
Keith Benedict
Software Engineer
Triad Systems Corporation



Quote:
> I am wondering if anyone could please send me an example of using the
> LogonUser API call written in VB.

> We are writting an application that needs to logon to the network and
would
> like to use this call.  I think our problem stems around the phToken that
> must be passed.  Which we have no idea about.

> Any help or examples would be greatly appreciated.

> Thanks,

> Jeff Levy





Mon, 31 May 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Repost: Help with LogonUser API call needed

2. LogonUser API call help needed

3. Pls Help! LogonUser API Problem

4. Pls Help! LogonUser API Problem

5. Help on LogonUser Api

6. LogonUser API call help.

7. Help with LogonUser API

8. Pls Help ! LogonUser Api Problem

9. LogonUser API Impersonation to SQL Server

10. Createprocesswithlogon and LogonUser APIs

11. LogonUser API function - question

12. Trouble with LogonUser API

 

 
Powered by phpBB® Forum Software