wilx
wilx

Reputation: 18238

Common Log File System API's RegisterManageableLogClient() and "access is denied" error

I am trying to use Microsoft's Common Log File System (CLFS) API. My code looks like this.

CLFS_MGMT_POLICY log_policy;
CLFS_INFORMATION log_info;
ULONG info_size = sizeof (log_info);
ULONGLONG desired_size;
ULONGLONG resulting_size;

data->log_handle = CreateLogFile (
    helpers::towstring (data->log_name).c_str (), GENERIC_WRITE,
    FILE_SHARE_DELETE | FILE_SHARE_WRITE | FILE_SHARE_READ, 0,
    OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE);

if (data->log_handle == INVALID_HANDLE_VALUE)
{
    loglog_win32_error (LOG4CPLUS_TEXT ("CreateLogFile()"));
    goto error;
}

if (! RegisterManageableLogClient (data->log_handle, 0))
{
    loglog_win32_error (LOG4CPLUS_TEXT ("RegisterManageableLogClient()"));
    goto error;
}

The CreateLogFile() function executes fine and I can even see a .blf file appear on file system. But RegisterManageableLogClient() returns with error and GetLastError() returns value 5 which is "Access is denied." This code is nearly identical to example on MSDN.

I cannot figure out why is the call to RegisterManageableLogClient() failing.

UPDATE:

The problem was missing GENERIC_READ for CreateLogFile().

Upvotes: 0

Views: 375

Answers (2)

wilx
wilx

Reputation: 18238

The problem was missing GENERIC_READ for CreateLogFile().

Upvotes: 0

mox
mox

Reputation: 6324

Since you are interacting with the policy, I guess you need Administrative credentials to perform the registration. This is why you get Access_denied.

Upvotes: 0

Related Questions