我正在使用本地库 ( libzmq ),它由 C# 包装器 ( clrzmq ) 调用。 IIS Web 应用程序(IIS 7.5、Windows Server 2008 R2、ASP.NET MVC 3)正在使用它。
native 库调用 CreateEvent()但是在使用 ApplicationPoolIdentity 运行 Web 应用程序时失败。如果我改用 LocalSystem 帐户,它会起作用,但我不想这样做。
我已经尝试过使用和不使用事件名称的“Global\”前缀。
有没有办法为 ApplicationPoolIdentity 提供所需的权限?
相关代码片段如下:
// Make the following critical section accessible to everyone.
SECURITY_ATTRIBUTES sa = {0};
sa.nLength = sizeof (sa);
sa.bInheritHandle = FALSE;
SECURITY_DESCRIPTOR sd;
BOOL ok = InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
win_assert (ok);
ok = SetSecurityDescriptorDacl(&sd, TRUE, (PACL) NULL, FALSE);
win_assert (ok);
sa.lpSecurityDescriptor = &sd;
// This function has to be in a system-wide critical section so that
// two instances of the library don't accidentally create signaler
// crossing the process boundary.
HANDLE sync = CreateEvent (&sa, FALSE, TRUE,
"Global\\zmq-signaler-port-sync");
win_assert (sync != NULL);
它在最后一行失败,因为 sync 为空。
供引用:
// Provides convenient way to check GetLastError-style errors on Windows.
#define win_assert(x) \
do {\
if (unlikely (!(x))) {\
char errstr [256];\
zmq::win_error (errstr, 256);\
fprintf (stderr, "Assertion failed: %s (%s:%d)\n", errstr, \
__FILE__, __LINE__);\
zmq::zmq_abort (errstr);\
}\
} while (false)
#endif
最佳答案
现在已经讨论并修复了这个问题:
关于c++ - 从 IIS 7.5 Web 应用程序调用 Win32 CreateEvent() 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11118493/