Support NULL-tokens in user_impersonator
Specifying NULL token is a no-op now. This simplifies client code when impersonation is optional. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
ae62e57126
commit
fa1514e9b3
@ -832,11 +832,11 @@ namespace winstd
|
|||||||
///
|
///
|
||||||
/// Construct the impersonator and impersonates the given user
|
/// Construct the impersonator and impersonates the given user
|
||||||
///
|
///
|
||||||
/// \param[in] hToken A handle to a primary or impersonation access token that represents a logged-on user
|
/// \param[in] hToken A handle to a primary or impersonation access token that represents a logged-on user or NULL for no impersonation.
|
||||||
///
|
///
|
||||||
/// \sa [ImpersonateLoggedOnUser function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378612.aspx)
|
/// \sa [ImpersonateLoggedOnUser function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378612.aspx)
|
||||||
///
|
///
|
||||||
user_impersonator(_In_ HANDLE hToken);
|
user_impersonator(_In_opt_ HANDLE hToken);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Reverts to current user and destructs the impersonator
|
/// Reverts to current user and destructs the impersonator
|
||||||
|
@ -283,9 +283,9 @@ winstd::actctx_activator::~actctx_activator()
|
|||||||
// winstd::user_impersonator
|
// winstd::user_impersonator
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
winstd::user_impersonator::user_impersonator(_In_ HANDLE hToken)
|
winstd::user_impersonator::user_impersonator(_In_opt_ HANDLE hToken)
|
||||||
{
|
{
|
||||||
m_cookie = ImpersonateLoggedOnUser(hToken);
|
m_cookie = hToken && ImpersonateLoggedOnUser(hToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user