How do I use Logonuser API in VB? 
Author Message
 How do I use Logonuser API in VB?

Does anyone have a working example in VB 5.0 of how to use Logonuser
API?

I tried the following, but id doesnt work.

Declared in Module1.bas:

Declare Function LogonUser Lib "ADVAPI32.DLL" Alias "LogonUserA" (ByVal
lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword
As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long,
phToken As Long) As Long

in the load of form1:

Dim Username As String, Domain As String
Dim Password As String, Type1 As Long
Dim Provider As Long, token As Long
Dim x As Long

Username = "Steve"
Domain = "stars"
Password = "miller"
Type1 = 0
Provider = 0
token = 0
x = LogonUser(Username, Domain, Password, Type1, Provider, token)

X comes back as 0, which means it was unsuccessful.
I even tried using "\\stars" for the domain and still get 0 for X.

Can anyone provide a working example?

Thanks!
Steve Miller



Thu, 01 Mar 2001 03:00:00 GMT  
 How do I use Logonuser API in VB?

[...]

You need to have the SeTcbPrivilege ("Act as part of the operating system")
to call LogonUser(). Otherwise, LogonUser() returns 0 and GetLastError()
returns 1314 (ERROR_PRIVILEGE_NOT_HELD).

Call AdjustTokenPrivilege() on your process's handle.
--
Damit Senanayake
ICQ#: 6930718
#include <stdio.h>
#include <ctype.h>
void main(){ const char*
s="\x044\x061\x06D\x069\x074\x020\x069\x073\x020\x040\x020\x061\x06C\x074\x0
61\x076\x069\x073\x074\x061\x02E\x06E\x065\x074"; char d[24]; for(int
i=0;i<25;i++) {d[i]=toascii(s[i]);} puts(d);}



Fri, 02 Mar 2001 03:00:00 GMT  
 How do I use Logonuser API in VB?
I have a similar .dll that is working fine for me from VB5 and from Windows
Scripting Host .vbs scripts.  My big (and I mean big) problem is that these
scripts won't work from my web VBScripts.  I always get a failure on the
LogonUser.  I suspect it's something I need to give the "Act as operating
system" rights to but I'm missing what it is.  I assumed IIS runs the
VBScripts with the 'system' account but it's definitely not working.  Any
thoughts?

Thanks,

John Granade


Quote:
>Steve,

>Try these files.  I use them to call the LogonUser method and they work
>fine.

>I have included a VBP and associated files of what I use.

>Just a note though, these were written by Bruce Owens, so I don't take
>credit for them. :)

>Ashton Hobbs



Sat, 03 Mar 2001 03:00:00 GMT  
 How do I use Logonuser API in VB?
if u r using IIS4 try throwing the RevertToSelf() function before throwing
LogonUser.

kirk

Quote:

>I have a similar .dll that is working fine for me from VB5 and from Windows
>Scripting Host .vbs scripts.  My big (and I mean big) problem is that these
>scripts won't work from my web VBScripts.  I always get a failure on the
>LogonUser.  I suspect it's something I need to give the "Act as operating
>system" rights to but I'm missing what it is.  I assumed IIS runs the
>VBScripts with the 'system' account but it's definitely not working.  Any
>thoughts?

>Thanks,

>John Granade



>>Steve,

>>Try these files.  I use them to call the LogonUser method and they work
>>fine.

>>I have included a VBP and associated files of what I use.

>>Just a note though, these were written by Bruce Owens, so I don't take
>>credit for them. :)

>>Ashton Hobbs



Mon, 05 Mar 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using LogonUSer API fails

2. Using LogonUSer API fails

3. Cant get LogonUser() to work in VB (Win32 API)

4. How do I use Logonuser API in VB?

5. How do I use Logonuser API in VB?

6. LogonUser API Impersonation to SQL Server

7. Createprocesswithlogon and LogonUser APIs

8. LogonUser API function - question

9. Trouble with LogonUser API

10. LogonUser API problem

11. Repost: Help with LogonUser API call needed

12. LogonUser API help

 

 
Powered by phpBB® Forum Software