我正在使用本地库(libzmq),它由C#包装器(clrzmq)调用。 IIS Web应用程序(IIS 7.5,Windows Server 2008 R2,ASP.NET MVC 3)正在使用它。
本机库调用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为null。
供参考:
// 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
答案 0 :(得分:0)