Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default LogonUser API call...

Hi,

Is there a reliable way to check a users username and password from
within a macro against an NT domain? I've tried using the Win32 API
call LogonUser, but without success, getting the
ERROR_PRIVILEGE_NOT_HELD error message.

Cheers for any help...

Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default LogonUser API call...

Hi,

This gets the username:

Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
'''''
' Copyright ©1996-2001 VBnet, Randy Birch, All Rights
Reserved.
' Some pages may also contain other copyrights by the
author.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
'''''
' You are free to use this code within your own
applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written
consent.
' This includes both posting free demo projects made from
this
' code as well as reproducing the code in text or html
format.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
'''''

Private Const MAX_USERNAME As Long = 256

Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Function rgbGetUserName() As String

'return the name of the user
Dim tmp As String

tmp = Space$(MAX_USERNAME)

If GetUserName(tmp, Len(tmp)) Then
rgbGetUserName = TrimNull(tmp)
End If

End Function

Private Function TrimNull(item As String)
Dim pos As Integer

pos = InStr(item, Chr$(0))

If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If

End Function

Don't know a way to get the password though.

Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
Hi,

Is there a reliable way to check a users username and

password from
within a macro against an NT domain? I've tried using the

Win32 API
call LogonUser, but without success, getting the
ERROR_PRIVILEGE_NOT_HELD error message.

Cheers for any help...

Paul
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default LogonUser API call...

Hi Paul,

You can do this with ADSI (search Google for "OpenDSObject" for more
information). But why do you want to do this? If there is a certain file
or folder you want to access, then just try it, and the user can
authenticate if needed. I for one would be hesitant to enter my network
username/password into a non-Windows dialog.

--
Regards,

Jake Marx
www.longhead.com


paul wrote:
Hi,

Is there a reliable way to check a users username and password from
within a macro against an NT domain? I've tried using the Win32 API
call LogonUser, but without success, getting the
ERROR_PRIVILEGE_NOT_HELD error message.

Cheers for any help...

Paul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default LogonUser API call...


This seemed to work for me when I tried it.

http://support.microsoft.com/support.../Q279/8/15.asp


Tim

"paul" wrote in message
om...
Hi,

Is there a reliable way to check a users username and password from
within a macro against an NT domain? I've tried using the Win32 API
call LogonUser, but without success, getting the
ERROR_PRIVILEGE_NOT_HELD error message.

Cheers for any help...

Paul



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default LogonUser API call...

Thanks chaps, Tim's suggestion works well and fast too. I couldn't get
the ADSI calls to work, Excel would't recognize the object types...

cheers,
Paul


"Tim Williams" wrote in message ...
This seemed to work for me when I tried it.

http://support.microsoft.com/support.../Q279/8/15.asp


Tim

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wouldn't know what to call it! 1Fish2Fish Excel Worksheet Functions 5 August 26th 08 07:37 PM
I'm not sure what you'd call it, but is it possible to do this? nut_mom Excel Discussion (Misc queries) 3 June 28th 06 06:17 PM
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM
Don't know what to call what I need? chanwando Excel Worksheet Functions 5 September 9th 05 10:01 PM
call sub Claudia Dell'Era[_2_] Excel Programming 3 October 3rd 03 01:31 PM


All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"