Detecting user from winsock data?
For example i create socket using winsock under account named Admin. Is there any possibility to detect which user created that socket? I would like to write in my program: This socket was c开发者_如何学Pythonreated by "Admin". i am using c++
Sockets are not securable objects (see here) and so cannot have a security descriptor associated with them and so there's no way you can know the user account that 'created the socket'.
You could use GetExtendedTcpTable to get information about connections and then locate the PID of the process that created the socket; you could then decide to use something based on the process...
Why do you want to do this anyway?
netstat -o
should give you process IDs which created the socket; from there, you can find the process owner. If everything else fails, you could spawn netstat in a new process and parse the output.
精彩评论