mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Implemented 'net ads printer search' which searches the directory for
published printers.
At the moment we don't search using any parameters but this can be
fixed by changing the LDAP search string. Also we should contact
the global catalog at SRV _gc._tcp instead of the ldap server we
get back from ads_startup().
(This used to be commit 814519c5de
)
This commit is contained in:
parent
d304a61cc7
commit
baf439cd55
@ -53,6 +53,20 @@ ADS_STATUS ads_find_printer_on_server(ADS_STRUCT *ads, void **res,
|
||||
return status;
|
||||
}
|
||||
|
||||
ADS_STATUS ads_find_printers(ADS_STRUCT *ads, void **res)
|
||||
{
|
||||
char *ldap_expr;
|
||||
const char *attrs[] = { "objectClass", "printerName", "location", "driverName",
|
||||
"serverName", "description", NULL };
|
||||
|
||||
/* For the moment only display all printers */
|
||||
|
||||
ldap_expr = "(&(!(showInAdvancedViewOnly=TRUE))(uncName=*)"
|
||||
"(objectCategory=printQueue))";
|
||||
|
||||
return ads_search(ads, res, ldap_expr, attrs);
|
||||
}
|
||||
|
||||
/*
|
||||
modify a printer entry in the directory
|
||||
*/
|
||||
@ -338,4 +352,3 @@ BOOL get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -726,6 +726,8 @@ int net_ads_join(int argc, const char **argv)
|
||||
int net_ads_printer_usage(int argc, const char **argv)
|
||||
{
|
||||
d_printf(
|
||||
"\nnet ads printer search <printer>"
|
||||
"\n\tsearch for a printer in the directory"
|
||||
"\nnet ads printer info <printer> <server>"
|
||||
"\n\tlookup info in directory for printer on server"
|
||||
"\n\t(note: printer defaults to \"*\", server defaults to local)\n"
|
||||
@ -738,6 +740,35 @@ int net_ads_printer_usage(int argc, const char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int net_ads_printer_search(int argc, const char **argv)
|
||||
{
|
||||
ADS_STRUCT *ads;
|
||||
ADS_STATUS rc;
|
||||
void *res = NULL;
|
||||
|
||||
if (!(ads = ads_startup()))
|
||||
return -1;
|
||||
|
||||
rc = ads_find_printers(ads, &res);
|
||||
|
||||
if (!ADS_ERR_OK(rc)) {
|
||||
d_printf("ads_find_printer: %s\n", ads_errstr(rc));
|
||||
ads_msgfree(ads, res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ads_count_replies(ads, res) == 0) {
|
||||
d_printf("No results found\n");
|
||||
ads_msgfree(ads, res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ads_dump(ads, res);
|
||||
ads_msgfree(ads, res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_ads_printer_info(int argc, const char **argv)
|
||||
{
|
||||
ADS_STRUCT *ads;
|
||||
@ -882,6 +913,7 @@ static int net_ads_printer_remove(int argc, const char **argv)
|
||||
static int net_ads_printer(int argc, const char **argv)
|
||||
{
|
||||
struct functable func[] = {
|
||||
{"SEARCH", net_ads_printer_search},
|
||||
{"INFO", net_ads_printer_info},
|
||||
{"PUBLISH", net_ads_printer_publish},
|
||||
{"REMOVE", net_ads_printer_remove},
|
||||
|
Loading…
Reference in New Issue
Block a user