summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-17 22:33:34 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-17 22:33:34 +0000
commitc945a9c97ffe476313ac64aa07f631c939654683 (patch)
treeda9c5911ff743bfb1124431dc750034f7f3e39a1 /source3/utils
parentc320f72f430d09bddbbf640feb8ee64b13e66f73 (diff)
downloadsamba-c945a9c97ffe476313ac64aa07f631c939654683.tar.gz
samba-c945a9c97ffe476313ac64aa07f631c939654683.tar.bz2
samba-c945a9c97ffe476313ac64aa07f631c939654683.zip
Merge from HEAD:
new 'net ads dn' doxygen fixes net help fixes. (This used to be commit de24fcb097ebf0d1aec92e787622cab64d10c553)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_ads.c69
-rw-r--r--source3/utils/net_help.c2
2 files changed, 68 insertions, 3 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 75bb29f213..8cd3bac802 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -53,6 +53,8 @@ int net_ads_usage(int argc, const char **argv)
"\n\t lookup, add, or remove directory entry for a printer\n"\
"\nnet ads search"\
"\n\tperform a raw LDAP search and dump the results\n"
+"\nnet ads dn"\
+"\n\tperform a raw LDAP search and dump attributes of a particular DN\n"
);
return -1;
}
@@ -131,7 +133,6 @@ static ADS_STRUCT *ads_startup(void)
if (opt_user_specified) {
need_password = True;
- use_in_memory_ccache();
}
retry:
@@ -142,8 +143,10 @@ retry:
free(prompt);
}
- if (opt_password)
+ if (opt_password) {
+ use_in_memory_ccache();
ads->auth.password = strdup(opt_password);
+ }
ads->auth.user_name = strdup(opt_user_name);
@@ -1002,7 +1005,7 @@ static int net_ads_search(int argc, const char **argv)
exp = argv[0];
attrs = (argv + 1);
- rc = ads_do_search_all(ads, ads->config.bind_path,
+ rc = ads_do_search_all(ads, ads->config.bind_path,
LDAP_SCOPE_SUBTREE,
exp, attrs, &res);
if (!ADS_ERR_OK(rc)) {
@@ -1022,6 +1025,65 @@ static int net_ads_search(int argc, const char **argv)
}
+/*
+ help for net ads search
+*/
+static int net_ads_dn_usage(int argc, const char **argv)
+{
+ d_printf(
+ "\nnet ads dn <dn> <attributes...>\n"\
+ "\nperform a raw LDAP search on a ADS server and dump the results\n"\
+ "The DN standard LDAP DN, and the attributes are a list of LDAP fields \n"\
+ "to show in the results\n\n"\
+ "Example: net ads dn 'CN=administrator,CN=Users,DC=my,DC=domain' sAMAccountName\n\n"
+ );
+ net_common_flags_usage(argc, argv);
+ return -1;
+}
+
+
+/*
+ general ADS search function. Useful in diagnosing problems in ADS
+*/
+static int net_ads_dn(int argc, const char **argv)
+{
+ ADS_STRUCT *ads;
+ ADS_STATUS rc;
+ const char *dn;
+ const char **attrs;
+ void *res = NULL;
+
+ if (argc < 1) {
+ return net_ads_dn_usage(argc, argv);
+ }
+
+ if (!(ads = ads_startup())) {
+ return -1;
+ }
+
+ dn = argv[0];
+ attrs = (argv + 1);
+
+ rc = ads_do_search_all(ads, dn,
+ LDAP_SCOPE_BASE,
+ "(objectclass=*)", attrs, &res);
+ if (!ADS_ERR_OK(rc)) {
+ d_printf("search failed: %s\n", ads_errstr(rc));
+ return -1;
+ }
+
+ d_printf("Got %d replies\n\n", ads_count_replies(ads, res));
+
+ /* dump the results */
+ ads_dump(ads, res);
+
+ ads_msgfree(ads, res);
+ ads_destroy(&ads);
+
+ return 0;
+}
+
+
int net_ads_help(int argc, const char **argv)
{
struct functable func[] = {
@@ -1057,6 +1119,7 @@ int net_ads(int argc, const char **argv)
{"CHOSTPASS", net_ads_change_localhost_pass},
{"PRINTER", net_ads_printer},
{"SEARCH", net_ads_search},
+ {"DN", net_ads_dn},
{"WORKGROUP", net_ads_workgroup},
{"LOOKUP", net_ads_lookup},
{"HELP", net_ads_help},
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index 782a530035..4000a248ff 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -47,6 +47,7 @@ int net_common_flags_usage(int argc, const char **argv)
d_printf("\t-U or --user=<name>\t\tuser name\n");
d_printf("\t-s or --conf=<path>\t\tpathname of smb.conf file\n");
d_printf("\t-l or --long\t\t\tDisplay full information\n");
+ d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
return -1;
}
@@ -160,6 +161,7 @@ static int net_usage(int argc, const char **argv)
" net rpc <command>\tto run RPC commands\n"\
"\n"\
"Type \"net help <option>\" to get more information on that option\n");
+ net_common_flags_usage(argc, argv);
return -1;
}