You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
3.0 KiB
169 lines
3.0 KiB
#ifndef _CUSTOMPROVIDER_HXX_
|
|
#define _CUSTOMPROVIDER_HXX_
|
|
|
|
class CUSTOM_USER_CONTEXT : public W3_USER_CONTEXT
|
|
{
|
|
public:
|
|
|
|
CUSTOM_USER_CONTEXT(
|
|
AUTH_PROVIDER * pProvider
|
|
) : W3_USER_CONTEXT( pProvider ),
|
|
_hImpersonationToken( NULL ),
|
|
_hPrimaryToken( NULL ),
|
|
_dwAuthType( 0 )
|
|
{
|
|
}
|
|
|
|
virtual ~CUSTOM_USER_CONTEXT()
|
|
{
|
|
if ( _hImpersonationToken != NULL )
|
|
{
|
|
CloseHandle( _hImpersonationToken );
|
|
_hImpersonationToken = NULL;
|
|
}
|
|
|
|
if ( _hPrimaryToken != NULL )
|
|
{
|
|
CloseHandle( _hPrimaryToken );
|
|
_hPrimaryToken = NULL;
|
|
}
|
|
}
|
|
|
|
HRESULT
|
|
Create(
|
|
HANDLE hImpersonationToken,
|
|
BYTE * pszUserName,
|
|
BOOL fIsUnicode,
|
|
DWORD dwAuthType
|
|
);
|
|
|
|
WCHAR *
|
|
QueryUserName(
|
|
VOID
|
|
)
|
|
{
|
|
return _strUserName.QueryStr();
|
|
}
|
|
|
|
WCHAR *
|
|
QueryPassword(
|
|
VOID
|
|
)
|
|
{
|
|
return L"";
|
|
}
|
|
|
|
DWORD
|
|
QueryAuthType(
|
|
VOID
|
|
)
|
|
{
|
|
return _dwAuthType;
|
|
}
|
|
|
|
HANDLE
|
|
QueryImpersonationToken(
|
|
VOID
|
|
)
|
|
{
|
|
return _hImpersonationToken;
|
|
}
|
|
|
|
HANDLE
|
|
QueryPrimaryToken(
|
|
VOID
|
|
);
|
|
|
|
PSID
|
|
QuerySid(
|
|
VOID
|
|
)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
private:
|
|
|
|
HANDLE _hImpersonationToken;
|
|
HANDLE _hPrimaryToken;
|
|
DWORD _dwAuthType;
|
|
STRU _strUserName;
|
|
CSpinLock _Lock;
|
|
};
|
|
|
|
class CUSTOM_AUTH_PROVIDER : public AUTH_PROVIDER
|
|
{
|
|
public:
|
|
|
|
CUSTOM_AUTH_PROVIDER()
|
|
{
|
|
}
|
|
|
|
virtual ~CUSTOM_AUTH_PROVIDER()
|
|
{
|
|
}
|
|
|
|
HRESULT
|
|
Initialize(
|
|
DWORD dwInternalId
|
|
)
|
|
{
|
|
SetInternalId( dwInternalId );
|
|
return NO_ERROR;
|
|
}
|
|
|
|
VOID
|
|
Terminate(
|
|
VOID
|
|
)
|
|
{
|
|
}
|
|
|
|
HRESULT
|
|
DoesApply(
|
|
W3_MAIN_CONTEXT * pMainContext,
|
|
BOOL * pfApplies
|
|
)
|
|
{
|
|
UNREFERENCED_PARAMETER( pMainContext );
|
|
UNREFERENCED_PARAMETER( pfApplies );
|
|
|
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
}
|
|
|
|
HRESULT
|
|
DoAuthenticate(
|
|
W3_MAIN_CONTEXT * pMainContext,
|
|
BOOL * pfFilterFinished
|
|
)
|
|
{
|
|
UNREFERENCED_PARAMETER( pMainContext );
|
|
UNREFERENCED_PARAMETER( pfFilterFinished );
|
|
|
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
}
|
|
|
|
HRESULT
|
|
OnAccessDenied(
|
|
W3_MAIN_CONTEXT * pMainContext
|
|
)
|
|
{
|
|
//
|
|
// No headers for anonymous
|
|
//
|
|
UNREFERENCED_PARAMETER( pMainContext );
|
|
|
|
return NO_ERROR;
|
|
}
|
|
|
|
DWORD
|
|
QueryAuthType(
|
|
VOID
|
|
)
|
|
{
|
|
return MD_AUTH_ANONYMOUS;
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|