EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to identify the user who originated a request

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#7058
Posted: 07/25/2008 12:40:25
by Christopher Nelson (Basic support level)
Joined: 07/25/2008
Posts: 3

We are attempting to determine the user who originated the request in certain events.

For example, to log the user who openned a file or who changed the attributes on a file.

I'm unclear if this is even possible with CallbackFilter.

Can I get some clarification about this?

If it is possible, a code example for C# or VB.NET would be much appreciated.
#7065
Posted: 07/26/2008 09:04:06
by Eugene Mayevski (EldoS Corp.)

Use GetOriginatorToken and/or GetOriginatorProcessName methods to obtain the corresponding information. Call those methods only from within the callbacks/event handlers. These methods are the same for all driver products and you will find several topics regarding these methods in Callback File System forum.


Sincerely yours
Eugene Mayevski
#7067
Posted: 07/26/2008 11:40:48
by Christopher Nelson (Basic support level)
Joined: 07/25/2008
Posts: 3

I suppose it's entirely possible that I'm missing something, but as best as I can tell, these GetOriginatorToken and/or GetOriginatorProcessName methods are only available in the Callback File System product and are not accessible from the CallbackFilter (CbFlt) class directly.

Are these methods based on p/invoke calls that I can call directly from within my handlers using only the CallbackFilter product in order to get the pointer to the originator token, or are you suggesting that we would need to use Callback File System to gain this functionality?

If the former is the case, I could use some pointers as to which API functions we would need to invoke in order to replicate this functionality in the callback filter event handlers without using the methods from the Callback file system product.

Again, any pointers to get is rolling along on this are greatly appreciated.

Thank you

Christopher


#7068
Posted: 07/26/2008 11:55:09
by Eugene Mayevski (EldoS Corp.)

Quote
Christopher Nelson wrote:
I suppose it's entirely possible that I'm missing something, but as best as I can tell, these GetOriginatorToken and/or GetOriginatorProcessName methods are only available in the Callback File System product and are not accessible from the CallbackFilter (CbFlt) class directly.


I have no clue why you think so. The methods are present in CallbackFilter.


Sincerely yours
Eugene Mayevski
#7069
Posted: 07/26/2008 13:53:21
by Christopher Nelson (Basic support level)
Joined: 07/25/2008
Posts: 3

Eugene,

Once again you are absolutely right. In my zest to go through this quickly, I didn't follow my logic through and was looking in the wrong place. Sorry for the confusion.

The following code seems to work as expected.

Code
    Private Sub CbFltPostOpenFileC(ByVal Sender As CbFlt.CallbackFilter, ByVal FileName As String, ByVal DesiredAccess As ACCESS_MASK, ByVal FileAttributes As UInt32, ByVal ShareMode As UInt32, ByRef UserContext As IntPtr)

        Dim iToken As IntPtr = Sender.GetOriginatorToken()

        UserContext = iToken

        If iToken <> 0 Then

            Dim objIdentity As New WindowsIdentity(iToken)

            objWriter.WriteLine("Post Open File Callback: " & FileName & " " & objIdentity.Name)
            objWriter.Flush()

        Else

            objWriter.WriteLine("Post Open File Callback: " & FileName & " UNKNOWN")
            objWriter.Flush()

        End If

    End Sub


Code
    Private Sub CbFltSetFileAttributesC(ByVal Sender As CbFlt.CallbackFilter, ByVal FileName As String, ByRef CreationTime As DateTime, ByRef LastAccessTime As DateTime, ByRef LastWriteTime As DateTime, ByVal FileAttributes As Int32, _
    ByRef UserContext As IntPtr, ByRef ProcessRequest As Boolean)

        Dim iToken As IntPtr = Sender.GetOriginatorToken()

        If iToken <> 0 Then

            Dim objIdentity As New WindowsIdentity(iToken)

            objWriter.WriteLine("Set Attributes Callback: " & FileName & " " & objIdentity.Name)
            objWriter.Flush()

        Else

            objWriter.WriteLine("Set Attributes Callback: " & FileName & " UNKNOWN")
            objWriter.Flush()
        End If

        ProcessRequest = True
    End Sub

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 4824 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!