Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


How to get SID of Remote User accessing the Shared files

Mahesh__DhannawatMahesh__Dhannawat Member Posts: 45
Hi All,

I have a Shared folder on my machine.If some remote user [who has access to shared folder] opens the shared file,i get the calls for this file in the context of System User.

I have used ZwOpenProcessTokenEx & ZwQueryInformationToken in IRP_MJ_CREATE to get SID, but it returns SID of system process & not that of the remote user who is accessing this file.

What should be done, to get SID of the remote user who is accessing my shared files ?


Thanks
Mahesh

Comments

  • I am not sure how it works for remote drive, but did you try to inspect IrpSp->Parameters.Create.SecurityContext->AccessState.SubjectSecurityContext? First inspect in debugger that ClientToken or PrimaryToken are not NULL then you can use SeXXX funcs below.

    pSubjectSecurityContext = &IrpSp->Parameters.Create.SecurityContext->AccessState.SubjectSecurityContext;
    SeLockSubjectContext(pSubjectSecurityContext);
    ClientToken = SeQuerySubjectContextToken(pSubjectSecurityContext);
    SeQueryInformationToken(ClientToken, TokenUser,...);
    SeUnlockSubjectContext(pSubjectSecurityContext);

    -bg
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Use Parameters.Create.SecurityContext->ClientToken if it is not NULL

    --
    Maxim Shatskih, Windows DDK MVP
    StorageCraft Corporation
    [email protected]
    http://www.storagecraft.com

    <[email protected]> wrote in message news:[email protected]
    > Hi All,
    >
    > I have a Shared folder on my machine.If some remote user [who has access to
    shared folder] opens the shared file,i get the calls for this file in the
    context of System User.
    >
    > I have used ZwOpenProcessTokenEx & ZwQueryInformationToken in IRP_MJ_CREATE
    to get SID, but it returns SID of system process & not that of the remote user
    who is accessing this file.
    >
    > What should be done, to get SID of the remote user who is accessing my shared
    files ?
    >
    >
    > Thanks
    > Mahesh
    >
  • Mahesh__DhannawatMahesh__Dhannawat Member Posts: 45
    Hi all,

    Thanks Bronislav & Maxim for your inputs.

    Using ClientToken [if it is not NULL] i got the SID of remote user who is accessing the shared file.

    Thanks
    Mahesh
  • jay96612jay96612 Member Posts: 16
    edited September 2

    Hey Mahesh_Dhannawat, Can you please tell how you get the SID of remote users accessing the file?I am doing the same thing but only getting local system user SID.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,158

    @jay96612 You’re asking... just in case the guy is around, 13 years later? Well, that certainly makes sense.

    Not.

    Do. Not. Necropost.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE