Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging in to Exchange Server 2000

Status
Not open for further replies.

jjogie

Programmer
Oct 23, 2000
3
CA
I am trying to log-in to Exchange 2000 using a script written in ASP or by making a COM object with VB. I do not want to use Oulook Web Access. Does anyone know where I can find the methods to do this. I have tried searching the documentation but I cannot seem to find the information that I need.
 
Option Explicit
Private Const LOGON32_PROVIDER_DEFAULT = 0
Private Const LOGON32_LOGON_BATCH = 4
Private Const LOGON32_LOGON_INTERACTIVE = 2
Private Const LOGON32_LOGON_SERVICE = 5

' Check Windows API for correct function calls
Private Declare Function RevertToSelfa Lib "advapi32.dll" Alias "RevertToSelf" () As Long
Private 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
Private Declare Function ImpersonateLoggedOnUsera Lib "advapi32.dll" Alias "ImpersonateLoggedOnUser" (ByVal hToken As Long) As Long

'local variable(s) to hold property value(s)
Private mvarusername As String 'local copy
Private mvarpassword As String 'local copy
Private mvardomain As String 'local copy
Private mvarservername As String 'local copy

Public Property Let servername(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.servername = 5
mvarservername = vData
End Property


Public Property Get servername() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.servername
servername = mvarservername
End Property



Public Property Let domain(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.domain = 5
mvardomain = vData
End Property


Public Property Get domain() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.domain
domain = mvardomain
End Property



Public Property Let password(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.password = 5
mvarpassword = vData
End Property


Public Property Get password() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.password
password = mvarpassword
End Property



Public Property Let username(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.username = 5
mvarusername = vData
End Property


Public Property Get username() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.username
username = mvarusername
End Property





Public Sub Authenticate()
Dim Result As Boolean, Token As Long

Result = RevertToSelfa()

Result = LogonUser(mvarusername, mvardomain, mvarpassword, LOGON32_LOGON_BATCH, LOGON32_PROVIDER_DEFAULT, Token)

If Result Then
Result = ImpersonateLoggedOnUsera(Token)
If Result Then
'client is athenticated
End If
End If
If Not Result Then
ErrorNumber = GetLastError
End If

End Sub

Public Sub Logoff()
Dim Result As Boolean
Result = RevertToSelfa()
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top