How can I get the domain name of the user making a print given the Job ID of the print?
I can get the user's name from, e.g., the JOB_INFO_2 retrieved via GetJob, but none of the JOB_INFO_# structures contain the user's domain name.
I can get the print server's domain using IPGlobalProperties.GetIPGlobalProperties().DomainName
, but that may not be the same as the user's domain, so it's not a reliable solution.
I don't know for sure, but it occurs to me that maybe the user name will include the user's domain (somelike name@domain), and maybe that only happens if the user is printing to a printer in another domain. It might be worth writing some code and checking this out.
Try using UserPrincipal.FindByIdentity(PrincipalContext, IdentityType, String) to find the user by username. Once the user is found, get the domain with that UserPrincipal's Context property.
You'll need to add a refernce to System.DirectoryServices.AccountManagement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With