0

私はC ++にかなり慣れていません...このコードでCreateEventが正常に機能しています:

HANDLE result = CreateEvent(NULL,                     // No security.
                            TRUE,                     // Manual-reset event.
                            FALSE,                    // Not signaled.
                            L"Global\\MyResetEvent"); // Event name.

しかし、C# で以下に相当するセキュリティ属性を使用するにはどうすればよいでしょうか?

SecurityIdentifier localSystemUsers = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
SecurityIdentifier adminUsers = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
EventWaitHandleAccessRule localSystemRule = new EventWaitHandleAccessRule(localSystemUsers, EventWaitHandleRights.FullControl, AccessControlType.Allow);
EventWaitHandleAccessRule adminRule = new EventWaitHandleAccessRule(adminUsers, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, AccessControlType.Allow);
EventWaitHandleSecurity security = new EventWaitHandleSecurity();
security.AddAccessRule(localSystemRule);
security.AddAccessRule(adminRule);
bool createdNew;
event = new EventWaitHandle(false, EventResetMode.ManualReset, MyEventName, out createdNew, security);
4

1 に答える 1

1

このリンクのおかげで、最終的にはこれでうまくいくはずだと思います:

    TCHAR *szSD = TEXT("D:")        // Discretionary ACL.
        TEXT("(A;OICI;GA;;;BA)");   // Allow full control to administrators.
        TEXT("(A;OICI;GA;;;SY)");   // Allow full control to the local system.
    SECURITY_ATTRIBUTES sa;
    sa.nLength = sizeof(SECURITY_ATTRIBUTES);
    sa.bInheritHandle = FALSE;
    ConvertStringSecurityDescriptorToSecurityDescriptor(szSD, SDDL_REVISION_1, &((&sa)->lpSecurityDescriptor), NULL);
    HANDLE result = CreateEvent(&sa, TRUE, FALSE, L"Global\\CustomManualResetEvent");
于 2013-09-17T12:17:01.867 に答える