Home COM GDI+ WebBrowser Data Access

IAuthenticate Interface

 

IID_IAuthenticate

{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}

 

 

This interface is implemented by the client application to provide the URL moniker with information to authenticate the user.

 

Urlmon.dll uses the QueryInterface method on the client application's implementation of IBindStatusCallback to obtain a pointer to the client application's IAuthenticate interface. If the client application is hosting Mshtml.dll, Mshtml.dll will request a pointer to the client application's implementation of IAuthenticate interface by calling QueryInterface on the client application's IServiceProvider interface.

 

 

Methods in VTable order

IUnknown Methods

Description

QueryInterface

Returns pointers to supported interfaces.

AddRef

Increments reference count.

Release

Decrements reference count.

IAuthenticate Method

Description

Authenticate

Supplies authentication support to a URL moniker from a client application.

 

IAuthenticate interface implementation

 


$IID_IAuthenticate = GUID$("{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}")

' ****************************************************************************************
' IAuthenticate interface virtual table
' ****************************************************************************************
TYPE IAuthenticateVtbl
   ' IUnknown methods
   pQueryInterface         AS DWORD          ' // QueryInterface method
   pAddRef                 AS DWORD          ' // AddRef method
   pRelease                AS DWORD          ' // Release method
   ' IAuthenticate method
   pAuthenticate           AS DWORD          ' // Authenticate method
   ' Custom data
   pVtblAddr               AS DWORD          ' // Address of the virtual table
   cRef                    AS DWORD          ' // Reference count
END TYPE
' ****************************************************************************************

' ****************************************************************************************
' Builds the IAuthenticate Virtual Table
' Returns a cookie that is a pointer to a IAuthenticateVtbl structure.
' ****************************************************************************************
FUNCTION IAuthenticate_BuildVtbl () AS DWORD

   LOCAL pVtbl AS IAuthenticateVtbl PTR
   LOCAL pUnk AS IAuthenticateVtbl PTR

   pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
   IF pVtbl = 0 THEN EXIT FUNCTION

   @pVtbl.pQueryInterface         = CODEPTR(IAuthenticate_QueryInterface)
   @pVtbl.pAddRef                 = CODEPTR(IAuthenticate_AddRef)
   @pVtbl.pRelease                = CODEPTR(IAuthenticate_Release)

   @pVtbl.pAuthenticate           = CODEPTR(IAuthenticate_Authenticate)

   @pVtbl.pVtblAddr               = pVtbl
   @pVtbl.cRef                    = 1

   pUnk = VARPTR(@pVtbl.pVtblAddr)
   FUNCTION = pUnk

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IAuthenticate_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IAuthenticate_QueryInterface (BYVAL pCookie AS IAuthenticateVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
   IF riid = $IID_IAuthenticate THEN
      ppvObj = pCookie
      INCR @@pCookie.cRef
      FUNCTION = %S_OK
   ELSE
      FUNCTION = %E_NOINTERFACE
   END IF
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IAuthenticate_IUnknown_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IAuthenticate_AddRef (BYVAL pCookie AS IAuthenticateVtbl PTR) AS DWORD
   INCR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IAuthenticate_IUnknown_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IAuthenticate_Release (BYVAL pCookie AS IAuthenticateVtbl PTR) AS DWORD
   DECR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
   IF @@pCookie.cRef = 0 THEN
      IF ISTRUE @@pCookie.pVtblAddr THEN
         HeapFree(GetProcessHeap(), 0, BYVAL @@pCookie.pVtblAddr)
      END IF
   END IF
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Supplies authentication support to a URL moniker from a client application.
' ****************************************************************************************
FUNCTION  IAuthenticate_Authenticate (BYVAL pCookie AS IAuthenticateVtbl PTR, BYREF pszUserName AS DWORD, BYREF pszPassword AS DWORD) AS LONG

   ' To read the UserName and Password passed to the function use:

   ' LOCAL strName AS STRING
   ' LOCAL strPassword AS STRING
   ' LOCAL bstrlen AS LONG
   ' IF pszName THEN
   '    bstrlen = lstrlenW(BYVAL pszUserName)
   '    IF bstrlen THEN
   '       strUserName = ACODE$(PEEK$(pszUserName, bstrlen * 2))
   '    END IF
   ' END IF
   ' IF pszPassword THEN
   '    bstrlen = lstrlenW(BYVAL pszPassword)
   '    IF bstrlen THEN
   '       strPassword = ACODE$(PEEK$(pszPassword, bstrlen * 2))
   '    END IF
   ' END IF

   ' To return different information:
   
   ' Free the memory allocated by the server
   ' IF pszUserName THEN CoTaskMemFree pszUserName
   ' IF pszPassword THEN CoTaskMemFree pszPassword
   ' Allocate new strings
   ' strName = UCODE$("My Name" & $NUL)
   ' pszUserName = CoTaskMemAlloc(LEN(strName))
   ' IF pszUserName THEN CopyMemory pszUserName, STRPTR(strName), LEN(strName)
   ' strPassword = UCODE$("My password" & $NUL)
   ' pszPassWord = CoTaskMemAlloc(LEN(strPassword))
   ' IF pszPassword THEN CopyMemory pszPassword, STRPTR(strPassword), LEN(strPassword)

   ' Put your code here
   ' FUNCTION = %S_OK or %E_ACCESSDENIED or %E_INVALIDARG
END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Monday, 03 April 2006 19:42:56 +0200