经典 ASP 和 ITaskScheduler 访问被拒绝错误

Classic ASP and ITaskScheduler access denied error

本文关键字:拒绝 错误 访问 ITaskScheduler ASP 经典      更新时间:2023-10-16

>我开发了一个COM+服务器组件(dll),它使用ITaskScheduler和ITask接口为我工作的公司创建的特定.exe创建和编辑任务。该组件是从经典的ASP页(VBScript)调用的,是我们正在开发的办公包的一部分。整个系统使用Web界面。在Windows Server 2003/2008上的IIS下运行时,我在尝试调用例如ITaskScheduler->Enum时遇到0x80070005拒绝访问错误。这是完全有道理的,IUsr_...帐户不应有权访问任务计划程序。我为用户添加了字段以在网页上输入其凭据,然后调用 LogonUser,然后在 COM 对象中调用 ImanalogateLoggedOnUser。但是,我仍然收到拒绝访问的错误。随后对 IServerSecurity->QueryBlanket 的调用显示 COM 对象仍在IUsr_下运行。帐户。我的登录逻辑如下:

bool SystemUser::LogonUser(const wchar_t* userName, const wchar_t* domain, const wchar_t* password)
{
    if(::LogonUser(userName, domain, password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &_token))
    {
        return true;
    }
    System::LogSystemError(__W_FILE__, __W_FUNCTION__, __LINE__, L"Unable to logon user: %s domain: %s", userName, domain);
    return false;
}
bool SystemUser::Impersonate()
{
    if(::ImpersonateLoggedOnUser(_token))
    {
        return true;
    }
    System::LogSystemError(__W_FILE__, __W_FUNCTION__, __LINE__, L"Unable to impersonate user");
    return false;
}
SuccessCode::Enum SystemUser::Logon(const wchar_t* userName, const wchar_t* domain, const wchar_t* password)
{
    if(!_token)
    {
        if(!LogonUser(userName, domain, password) || !Impersonate())
        {
            return SuccessCode::ImpersonateError;
        }
        else
        {
            Global::systemLog.Write(LogLevel::Information, L"Successfully logged on as user: '%s' domain: '%s'", userName, domain);
        }
    }
    return SuccessCode::Success;
}

使用 LOGON32_LOGON_INTERACTIVE 作为登录类型没有区别。在 COM+ MMC 中设置特定角色也是如此。任何帮助或建议非常感谢。

此问题的解决方案是将登录和模拟逻辑移动到单独的 COM 对象。在创建任务计划对象的实例并调用其代码之前,需要在 ASP 和调用的登录代码中创建此实例。这样,模拟逻辑将应用于 ASP。现在可以看到 ASP 在模拟帐户下运行。