diff options
author | Jim McDonough <jmcd@samba.org> | 2002-11-18 19:50:36 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-11-18 19:50:36 +0000 |
commit | bbd3e4b40a511bff8656e11fa993dce26e02aa0f (patch) | |
tree | 0f0d8ca2c1b2889f2c34cea1b378baa5dd3afabc /source3/utils | |
parent | 28a61607a7c0cd2347ac0b71e26ff52a393c4121 (diff) | |
download | samba-bbd3e4b40a511bff8656e11fa993dce26e02aa0f.tar.gz samba-bbd3e4b40a511bff8656e11fa993dce26e02aa0f.tar.bz2 samba-bbd3e4b40a511bff8656e11fa993dce26e02aa0f.zip |
Next step of printer publishing.
net ads printer publish <printername> [servername]
Will retreive the DsSpooler and DsDriver info by rpc for a remote server
then publish it.
Next comes doing it within smbd
(This used to be commit 64951938cc5666a757683cbe9bee3a2c20a05323)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_ads.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index b138f67aa3..bb311b9b30 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -69,13 +69,13 @@ static int net_ads_lookup(int argc, const char **argv) ads->auth.flags |= ADS_AUTH_NO_BIND; } - ads_connect(ads); + /* ads_connect(ads); if (!ads || !ads->config.realm) { d_printf("Didn't find the cldap server!\n"); return -1; } - + */ return ads_cldap_netlogon(ads); } @@ -116,7 +116,7 @@ static ADS_STRUCT *ads_startup(void) BOOL need_password = False; BOOL second_time = False; - ads = ads_init(NULL, NULL, opt_host); + ads = ads_init(lp_realm(), NULL, opt_host); if (!opt_user_name) { opt_user_name = "administrator"; @@ -743,42 +743,45 @@ static int net_ads_printer_publish(int argc, const char **argv) { ADS_STRUCT *ads; ADS_STATUS rc; - char *uncname, *servername; - ADS_PRINTER_ENTRY prt; - char *ports[2] = {"Samba", NULL}; - - /* - these const strings are only here as an example. The attributes - they represent are not implemented yet - */ - const char *bins[] = {"Tray 21", NULL}; - const char *media[] = {"Letter", NULL}; - const char *orients[] = {"PORTRAIT", NULL}; + char *servername; + struct cli_state *cli; + struct in_addr server_ip; + NTSTATUS nt_status; + extern char *opt_workgroup; + TALLOC_CTX *mem_ctx = talloc_init(); + ADS_MODLIST mods = ads_init_mods(mem_ctx); + char *prt_dn, *srv_dn, **srv_cn; + void *res = NULL; if (!(ads = ads_startup())) return -1; if (argc < 1) return net_ads_printer_usage(argc, argv); - - memset(&prt, 0, sizeof(ADS_PRINTER_ENTRY)); - - /* we don't sue the servername or unc name provided by - get_a_printer, because the server name might be - localhost or an ip address */ - prt.printerName = argv[0]; - asprintf(&servername, "%s.%s", global_myname(), ads->config.realm); - prt.serverName = servername; - prt.shortServerName = global_myname(); - prt.versionNumber = "4"; - asprintf(&uncname, "\\\\%s\\%s", global_myname(), argv[0]); - prt.uNCName=uncname; - prt.printBinNames = (char **) bins; - prt.printMediaSupported = (char **) media; - prt.printOrientationsSupported = (char **) orients; - prt.portName = (char **) ports; - prt.printSpooling = "PrintAfterSpooled"; - - rc = ads_add_printer(ads, &prt); + + if (argc = 2) + servername = argv[1]; + else + servername = global_myname(); + + ads_find_machine_acct(ads, &res, servername); + srv_dn = ldap_get_dn(ads->ld, res); + srv_cn = ldap_explode_dn(srv_dn, 1); + asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn[0], argv[0], srv_dn); + + resolve_name(servername, &server_ip, 0x20); + + nt_status = cli_full_connection(&cli, global_myname(), servername, + &server_ip, 0, + "IPC$", "IPC", + opt_user_name, opt_workgroup, + opt_password ? opt_password : "", + CLI_FULL_CONNECTION_USE_KERBEROS, + NULL); + + cli_nt_session_open(cli, PI_SPOOLSS); + get_remote_printer_publishing_data(cli, mem_ctx, &mods, argv[0]); + + rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods); if (!ADS_ERR_OK(rc)) { d_printf("ads_publish_printer: %s\n", ads_errstr(rc)); return -1; |