In Windows, when using a local PC account and trying to access the network printer share (ie typing "\printershare" in the Run window), a box pops up asking for a domain user's username and password.
Put in a domain user's username and password, and then the printer share appears using the domain user's credentials.
How can this be achieved via C#?
I have tried the following methods:
var printerShare = new DirectoryEntry(@"\\printershare\", "username", "password");
var printerShare = new DirectoryEntry(@"WinNT://printershare\", "username", "password");
var printerShare = new DirectoryEntry(@"WinNT:\\printershare\", "username", "password");
var printerShare = new DirectoryEntry("LDAP://printershare.corp.domain.com", "username", "password");
var printerShare = new DirectoryEntry("LDAP:\\printershare.corp.domain.com", "username", "password");
Unfortunately, none of them work. Mapping a network directory or folder would be simple.
But the fact that there are no folders is what is making me scratch my head.
Anyone know what I'm doing wrong here?