I have a windows network (peer-2-peer) as well as Active Directory and I need to log the name of users who send any kind of print to the server.
I want to write a program to log their username and/or their respective IP and I’m familiar with c#.net and c++ but I haven’t found any clue regarding how to solve my problem.
is there any sorts of way to catch their name by the help of WMI or should dirty my hand with APIs(but which API I don’t have any idea)?
regards.
Those features are exposed under the Spooler API.
EnumJobswill enumerate all the current jobs for a given printer. It will return aJOB_INFO_1struct, which includes the username associated with a given print job:If you’d prefer WMI, you can use
wmic.exewith the/nodeswitch (or your preferred variation) and theWin32_PrintJobclass. Roughly:…will return a struct with all the print job information for the selected server. You can filter as you wish with the
WHEREclause.