Discussion:
SetJob Acces_denied
(too old to reply)
Cedric
2006-07-28 09:10:01 UTC
Permalink
Hello,
I'm trying to use The SetJob API so for testing purpose I call Getjob to
retreive a valid structure JOB_INFO_2 And then I call SetJob with the same
structure.

But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use OpenPrinter with
desiredAccess set to PRINTER_ALL_ACCESS.

I red something about the value of JOB_INFO_2's member SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.

Thanks For Help.
Mark Yudkin
2006-07-30 11:42:44 UTC
Permalink
I suspect the access denied refers to the job, not the printer. How are you
obtaining the job id?
Post by Cedric
Hello,
I'm trying to use The SetJob API so for testing purpose I call Getjob to
retreive a valid structure JOB_INFO_2 And then I call SetJob with the same
structure.
But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use OpenPrinter with
desiredAccess set to PRINTER_ALL_ACCESS.
I red something about the value of JOB_INFO_2's member SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.
Thanks For Help.
Cedric
2006-07-30 14:31:01 UTC
Permalink
Hello,

I pause the printer and print test page.

After that, to get jobId I first test EnumJob's sample found in msdn. So I
retreive all jobid.

And now I try to change job properties with SetJob.
Post by Mark Yudkin
I suspect the access denied refers to the job, not the printer. How are you
obtaining the job id?
Post by Cedric
Hello,
I'm trying to use The SetJob API so for testing purpose I call Getjob to
retreive a valid structure JOB_INFO_2 And then I call SetJob with the same
structure.
But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use OpenPrinter with
desiredAccess set to PRINTER_ALL_ACCESS.
I red something about the value of JOB_INFO_2's member SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.
Thanks For Help.
Mark Yudkin
2006-07-31 16:56:19 UTC
Permalink
AFAIK you can't do this. SetJob, when setting properties, has to be done
when the job is created. Once you've created the job, you can't alter all of
its properties. You will need to strip out all of properties that you may
not alter.
Post by Cedric
Hello,
I pause the printer and print test page.
After that, to get jobId I first test EnumJob's sample found in msdn. So I
retreive all jobid.
And now I try to change job properties with SetJob.
Post by Mark Yudkin
I suspect the access denied refers to the job, not the printer. How are you
obtaining the job id?
Post by Cedric
Hello,
I'm trying to use The SetJob API so for testing purpose I call Getjob to
retreive a valid structure JOB_INFO_2 And then I call SetJob with the same
structure.
But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use OpenPrinter with
desiredAccess set to PRINTER_ALL_ACCESS.
I red something about the value of JOB_INFO_2's member
SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.
Thanks For Help.
Cedric
2006-08-01 08:17:02 UTC
Permalink
Hello, thanks for that . It's working when I just copy few members.

But another question about the array's size. In fact, the array's size
return by the GetJob is bigger than size return by Marshal.Sizeof(Structure),
Why ?

It's seems that the array must be big enough to store all string, but if I
modify string how to calculate size needed ?

Thanks
Post by Mark Yudkin
AFAIK you can't do this. SetJob, when setting properties, has to be done
when the job is created. Once you've created the job, you can't alter all of
its properties. You will need to strip out all of properties that you may
not alter.
Post by Cedric
Hello,
I pause the printer and print test page.
After that, to get jobId I first test EnumJob's sample found in msdn. So I
retreive all jobid.
And now I try to change job properties with SetJob.
Post by Mark Yudkin
I suspect the access denied refers to the job, not the printer. How are you
obtaining the job id?
Post by Cedric
Hello,
I'm trying to use The SetJob API so for testing purpose I call Getjob to
retreive a valid structure JOB_INFO_2 And then I call SetJob with the same
structure.
But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use OpenPrinter with
desiredAccess set to PRINTER_ALL_ACCESS.
I red something about the value of JOB_INFO_2's member
SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.
Thanks For Help.
Mark Yudkin
2006-08-01 09:22:51 UTC
Permalink
Post by Cedric
Post by Mark Yudkin
Post by Cedric
Marshal.Sizeof(Structure)
Isn't this VB.NET? If so, please ignore all of my posts, as they are for VB6
only and are inapplicable in your case. Moreover, I have no idea how to
solve your issue if it's for VB.NET. Furthermore I cannot answer your
question regarding Marshal.Sizeof(Structure).

For VB6, the answer is that the array size (byte count) is returned by
GetJob in pcbNeeded.
Post by Cedric
Hello, thanks for that . It's working when I just copy few members.
But another question about the array's size. In fact, the array's size
return by the GetJob is bigger than size return by
Marshal.Sizeof(Structure),
Why ?
It's seems that the array must be big enough to store all string, but if I
modify string how to calculate size needed ?
Thanks
Post by Mark Yudkin
AFAIK you can't do this. SetJob, when setting properties, has to be done
when the job is created. Once you've created the job, you can't alter all of
its properties. You will need to strip out all of properties that you may
not alter.
Post by Cedric
Hello,
I pause the printer and print test page.
After that, to get jobId I first test EnumJob's sample found in msdn.
So
I
retreive all jobid.
And now I try to change job properties with SetJob.
Post by Mark Yudkin
I suspect the access denied refers to the job, not the printer. How
are
you
obtaining the job id?
Post by Cedric
Hello,
I'm trying to use The SetJob API so for testing purpose I call
Getjob
to
retreive a valid structure JOB_INFO_2 And then I call SetJob with
the
same
structure.
But result of SetJob is an Error 5 : ACCESS_DENIED. I don't understand
because I'm PC's Administrator, my printer is local, I use
OpenPrinter
with
desiredAccess set to PRINTER_ALL_ACCESS.
I red something about the value of JOB_INFO_2's member
SecurityDescriptor
that must be set to null before calling SetJob but is already set to null.
Thanks For Help.
Loading...