-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify which user is connected #7
Comments
Added in the latest release. Usage: server.ClientConnected += async (o, args) =>
{
var name = args.Connection.GetImpersonationUserName();
Console.WriteLine($"Client {name} is now connected!");
}; |
Yes, I forgot to release new versions of Formatter packages after refactoring. Should be fixed in the latest version. |
Awesome, that worked 👍 Looking further into it, there also seems like there is a way to get the PID of the client process `[DllImport("kernel32.dll", SetLastError = true)] int GetNamedPipeClientProcessId(NamedPipeServerStream pipeServer)
}` This works great if called straight from the NamedPipeServerStream, but this is not exposed in H.Pipes. Could this also be implemented? |
I have moved PipeConnection.PipeStream to public properties for advanced use. /// <summary>
/// Raw pipe stream. You can cast it to <see cref="NamedPipeClientStream"/> or <see cref="NamedPipeServerStream"/>.
/// </summary>
public PipeStream PipeStream { get; } |
I found a way 🤡 I'm not quite sure were to place the dll reference, I did a temporary placement in EventExtensions.cs /// Gets the process PID of the client on the other end of the pipe. /// /// The process PID of the client on the other end of the pipe. /// is not . /// No pipe connections have been made yet. /// The connected pipe has already disconnected. /// The pipe handle has not been set. /// The pipe is closed. /// The pipe connection has been broken. /// The process PID of the client is longer than 19 characters. public int GetNamedPipeClientProcessId() { if (PipeStream is not NamedPipeServerStream serverStream) { throw new InvalidOperationException($"{nameof(PipeStream)} is not {nameof(NamedPipeServerStream)}."); }
` We can then call it the same way as GetImpersonationUserName
|
I am guessing that you can just add an Extension method for the |
Absolutely, thanks for all the help. |
Hi,
In System.IO.Pipes there is a function "GetImpersonationUserName()" for getting the username of the user connecting.
Have you looked into adding similar capabilities?
This would need to be handled server side to avoid the possibility of a user impersonating another user.
The text was updated successfully, but these errors were encountered: