Hi All,
I am seeing a different behavior between legacy driver and MiniFilter
driver when i am trying to get the SID of the requesting thread.
I have one folder shared on my server and clients are accessing that
share. Let’s say user2 is logged into the client system, then system
impersonate to system/NT Authority and sends the request down the stack.
So far so good.
I am trying to get the SID of the requesting thread in PreCreate (i am
not interested in SID of the impersonating thread). I tried to search
about this issue but only found the FAQ on OSR Site
"For remote calls, however, the CIFS server routinely utilizes
impersonation during IRP_MJ_CREATE and for some IRP_MJ_SET_INFORMATION
operations. Otherwise, the CIFS server uses the local system’s
credentials. To handle this case, a filter must store away the
credential information of the original caller. In the case of
IRP_MJ_CREATE the original caller’s token is specified as part of the
IO_SECURITY_CONTEXT parameter. The ACCESS_STATE structure in turn
contains the SECURITY_SUBJECT_CONTEXT and the filter can retrieve a
pointer to the token using SeQuerySubjectContextToken. The SID can then
be retrieved from the token using SeQueryInformationToken.
"
This is exactly what i did and below is the code snippet.
But i don’t get the SID of the requesting thread. When i dug deep into
this, this is what i found in _SECURITY_SUBJECT_CONTEXT structure in my
minifilter driver.
ClientToken = NULL;
ImpersonationLevel = SecurityAnonymous; ??
PrimaryToken = “token of impersonating thread (system/NT Authority)”;
Why i am unable to get the clienttoken in minifilter? or how do i get
the SID of the requesting thread in minifilter?
When i install my legacy driver, i am able to get the clienttoken. No
changes in the system setup or anywhere else. Its the same call, same
request.
Here is the code…
Token2 =
SeQuerySubjectContextToken(&(Cbd->Iopb->Parameters.Create.SecurityContext->AccessState->SubjectSecurityContext));
// Get User SID
Status = SeQueryInformationToken(Token, TokenUser, (PVOID *) & kenUser);
if (!NT_SUCCESS(Status)) {
DoTraceLevelMessage(TRACE_LEVEL_CRITICAL, FILE_TRACE_FLAG,
“%s SeQueryInformationToken(File - %wZ, Token - %p, Cbd - %p,
TOKEN_USER) failed with error - 0x%X\n”,
TRACE_PREFIX,
FILENAME_FROM_FILEOBJECT
(FltObjects->FileObject), Token, Cbd,
Status);
LEAVE;
}
thanks in advance