Author: jmcd
Date: 2004-11-14 03:12:46 +0000 (Sun, 14 Nov 2004)
New Revision: 3727

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=3727

Log:
Update from Rob Foehl ([EMAIL PROTECTED]):
Try modifying printer before adding it,since add logic appends ObjectClass to 
mods, which caused a contraint violation when modifying an already published 
printer.

Also cleanup the check_published_printers() logic when verifying published 
status on startup.

Modified:
   branches/SAMBA_3_0/source/printing/nt_printing.c


Changeset:
Modified: branches/SAMBA_3_0/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/nt_printing.c    2004-11-13 18:20:33 UTC 
(rev 3726)
+++ branches/SAMBA_3_0/source/printing/nt_printing.c    2004-11-14 03:12:46 UTC 
(rev 3727)
@@ -2707,9 +2707,12 @@
                    printer->info_2->sharename);
 
        /* publish it */
-       ads_rc = ads_add_printer_entry(ads, prt_dn, ctx, &mods);
-       if (LDAP_ALREADY_EXISTS == ads_rc.err.rc)
-               ads_rc = ads_mod_printer_entry(ads, prt_dn, ctx, &mods);
+       ads_rc = ads_mod_printer_entry(ads, prt_dn, ctx, &mods);
+       if (ads_rc.err.rc == LDAP_NO_SUCH_OBJECT)
+               ads_rc = ads_add_printer_entry(ads, prt_dn, ctx, &mods);
+
+       if (!ADS_ERR_OK(ads_rc))
+               DEBUG(3, ("error publishing %s: %s\n", 
printer->info_2->sharename, ads_errstr(ads_rc)));
        
        talloc_destroy(ctx);
 
@@ -2831,11 +2834,9 @@
 {
        ADS_STATUS ads_rc;
        ADS_STRUCT *ads = NULL;
-       void *res = NULL;
        int snum;
        int n_services = lp_numservices();
        NT_PRINTER_INFO_LEVEL *printer = NULL;
-       WERROR win_rc;
 
        ads = ads_init(NULL, NULL, NULL);
        if (!ads) {
@@ -2859,27 +2860,12 @@
                if (!(lp_snum_ok(snum) && lp_print_ok(snum)))
                        continue;
 
-               if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2,
-                                                lp_servicename(snum))) ||
-                   !(printer->info_2->attributes & 
PRINTER_ATTRIBUTE_PUBLISHED))
-                       goto next;
+               if (W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2,
+                                               lp_servicename(snum))) &&
+                   (printer->info_2->attributes & PRINTER_ATTRIBUTE_PUBLISHED))
+                       nt_printer_publish_ads(ads, printer);
 
-               DEBUG(5, ("checking directory for printer %s\n", 
printer->info_2->printername));
-               ads_rc = ads_find_printer_on_server(ads, &res,
-                               printer->info_2->sharename, global_myname());
-               if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) {
-                       DEBUG(5, ("printer %s is in directory\n", 
printer->info_2->printername));
-                       goto next;
-               }
-
-               win_rc = nt_printer_publish_ads(ads, printer);
-               if (!W_ERROR_IS_OK(win_rc))
-                       DEBUG(3, ("error publishing %s: %s\n", 
printer->info_2->sharename, dos_errstr(win_rc)));
-
-       next:
                free_a_printer(&printer, 2);
-               ads_msgfree(ads, res);
-               res = NULL;
        }
 
        ads_destroy(&ads);

Reply via email to