1

I'm using print server:

PrintServer myPrintServer = new PrintServer(@"\\printsrv");

but I get exception:

An exception occurred while creating the PrintServer object. Win32 error: The user name or password is incorrect.

How can I pass username and password?

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
Frogger
  • 48
  • 7

1 Answers1

1

You'll need to have the network credentials cached for that server. I think the easiest way is to start a net use command from code:

var p = new Process();
p.StartInfo.FileName = "net";
p.StartInfo.Arguments = "use \\printsrv password /user:domain\username";
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();

After that the PrintServer class should be able to connect. You could also try these answers to get the credentials cached beforehand.

Community
  • 1
  • 1
huysentruitw
  • 27,376
  • 9
  • 90
  • 133