summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-09-15 15:27:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:51:49 -0500
commite5b3b3cac5c328cc0afcff1c33cf65e38ab6329d (patch)
tree5b2dd634acde8e29693a895fdee103fa56184e75 /source3
parenta0aaa82f6d360f2fe688f95791640b58231ed873 (diff)
downloadsamba-e5b3b3cac5c328cc0afcff1c33cf65e38ab6329d.tar.gz
samba-e5b3b3cac5c328cc0afcff1c33cf65e38ab6329d.tar.bz2
samba-e5b3b3cac5c328cc0afcff1c33cf65e38ab6329d.zip
r18556: Implement "net sam policy", thanks to Karolin Seeger <ks@sernet.de>.
Volker (This used to be commit da22aa7021d42a940d8f2151770fedbd2abdb63a)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_sam.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index 9edbc7b8cf..00289d3bd3 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -387,6 +387,80 @@ static int net_sam_set(int argc, const char **argv)
}
/*
+ * Change account policies
+ */
+
+static int net_sam_policy(int argc, const char **argv)
+{
+
+ const char *account_policy = NULL;
+ uint32 value, old_value;
+ int field;
+
+ if ((argc < 1) || (argc > 2)) {
+ d_fprintf(stderr, "usage: net sam policy \"<account policy>\" "
+ "-> show current value\n");
+ d_fprintf(stderr, "usage: net sam policy \"<account policy>\" "
+ "<value> -> set a new value\n");
+ return -1;
+ }
+
+ account_policy = argv[0];
+ field = account_policy_name_to_fieldnum(account_policy);
+
+ if (field == 0) {
+ char *apn = account_policy_names_list();
+ d_fprintf(stderr, "No account policy by that name!\n");
+ if (apn) {
+ d_fprintf(stderr, "Valid account policies "
+ "are:\n%s\n", apn);
+ }
+ SAFE_FREE(apn);
+ return -1;
+ }
+
+ if (!pdb_get_account_policy(field, &old_value)) {
+ fprintf(stderr, "Valid account policy, but unable to "
+ "fetch value!\n");
+ return -1;
+ }
+
+ if (argc == 1) {
+ /*
+ * Just read the value
+ */
+
+ printf("Account policy \"%s\" description: %s\n",
+ account_policy, account_policy_get_desc(field));
+ printf("Account policy \"%s\" value is: %d\n", account_policy,
+ old_value);
+ return 0;
+ }
+
+ /*
+ * Here we know we have 2 args, so set it
+ */
+
+ value = strtoul(argv[1], NULL, 10);
+
+ printf("Account policy \"%s\" description: %s\n", account_policy,
+ account_policy_get_desc(field));
+ printf("Account policy \"%s\" value was: %d\n", account_policy,
+ old_value);
+
+ if (!pdb_set_account_policy(field, value)) {
+ d_fprintf(stderr, "Setting account policy %s to %u failed \n",
+ account_policy, value);
+ }
+
+ printf("Account policy \"%s\" value is now: %d\n", account_policy,
+ value);
+
+ return 0;
+}
+
+
+/*
* Map a unix group to a domain group
*/
@@ -1232,6 +1306,8 @@ int net_sam(int argc, const char **argv)
"Show details of a SAM entry" },
{ "set", net_sam_set,
"Set details of a SAM account" },
+ { "policy", net_sam_policy,
+ "Set account policies" },
#ifdef HAVE_LDAP
{ "provision", net_sam_provision,
"Provision a clean User Database" },