Bug 11665 - When connecting to printers with "List in Directory" set but aren't in the directory fails
Summary: When connecting to printers with "List in Directory" set but aren't in the di...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: printing (show other bugs)
Version: unspecified
Hardware: All All
: P5 regression (vote)
Target Milestone: ---
Assignee: Guenther Deschner
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-08 14:28 UTC by Colin.Simpson
Modified: 2020-09-08 13:57 UTC (History)
5 users (show)

See Also:


Attachments
Proposed patch for master (2.45 KB, patch)
2016-11-08 14:17 UTC, Andreas Schneider
no flags Details
patch for 4.5 (2.51 KB, patch)
2016-11-08 17:21 UTC, Andreas Schneider
asn: review? (gd)
Details
patch for 4.4 (2.51 KB, patch)
2016-11-08 17:22 UTC, Andreas Schneider
asn: review? (gd)
Details
patch for 3.6 (2.48 KB, patch)
2016-11-08 17:22 UTC, Andreas Schneider
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Colin.Simpson 2016-01-08 14:28:03 UTC
This is a change in behaviour i.e. if "List in Directory" was ticked but it isn't published really in AD (removed by some other means etc), it will no longer allow you to "Connect" to it. It used to. 

But you also cannot untick "List in Director" in the GUI as Samba can't find the printer in AD (funally enough as it isn't published). But maybe it should still allow this to be unticked, even if not in AD?  Not sure...

This is possibly related to Bug #11018 - "smbd can't find the GUID for a printer in the registry and fails to publish printers" and the fix for this.


To reproduce:

1/ Ensure you have a printer that isn't published in AD, and "List in Directory" is unticked. And ensure you can install drivers for it. 

2/ Stop Samba

3/ net registry export HKLM /root/samba.reg

3/ Then edit /root/samba.reg and look for the keys like:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Printername

Where Printername is the name of your printer.

For example I have a key.

[HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\dell3130cn1]

my printer is called "dell3130cn1".

4/ Under here there is an entry "Attributes".  From my case:

"Attributes"=dword:00001848"

The "List in Directory" setting appears to be controlled by bit 14
 (counting from least significant)

In practice we have the same value (presumably all other settings
represented by this key are common to all our printers) so it was easy
i.e. I have
List in Directory NOT set - 01100001001000 - 6216(decimal) - 1848 (hex)

List in Directory set - 11100001001000 - 14408 (decimal) - 3848 (hex)

Put in a new value with this bit 14 flipped to 1 (and the rest of the
values as before) and convert back into hex. Then this is your new
value for this attributes key. For my case change to: 

"Attributes"=dword:00003848"

6/ Import this edited  registry back into Samba.

net registry import /root/samba.reg

7/ Start Samba and see if from a Windows machine this "List in
Directory" is now set.

8/ Trying to install the drivers should now fail (if you cleared out Windows of the driver installs). Windows machine returns "Windows cannot connect to the printer" "Operation failed with error 0x00000002". And the log has an entry "Failed to get GUID for printer"

9/ Also observe that the "List in Directory" tick box cannot be unticked.
Comment 1 Andreas Schneider 2016-11-08 14:17:17 UTC
Created attachment 12633 [details]
Proposed patch for master
Comment 2 Andreas Schneider 2016-11-08 17:21:18 UTC
Created attachment 12634 [details]
patch for 4.5
Comment 3 Andreas Schneider 2016-11-08 17:22:07 UTC
Created attachment 12635 [details]
patch for 4.4
Comment 4 Andreas Schneider 2016-11-08 17:22:55 UTC
Created attachment 12636 [details]
patch for 3.6
Comment 5 Stefan Metzmacher 2017-04-07 15:55:01 UTC
Ping, should we backport this to 4.5, is it enough to have it 4.6?
Comment 6 Björn Jacke 2019-12-05 13:26:14 UTC
as far as I can see one of the problems was that the ticking and unticking of the "publish in AD" feature doesn't work. I still observed the same issue recently with an up-to-date windows machine's print manager and an up-to-date 4.11 samba print server. So this issue didn't get fixed with the patches here so far.
Comment 7 Björn Jacke 2020-09-08 07:54:20 UTC
(In reply to Björn Jacke from comment #6)
the mentioned problem is a result of bug 9771. Closing  and leaving alone this bug report here again.