[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-718-g0d79560
Günther Deschner
gd at samba.org
Wed Apr 9 11:29:43 GMT 2008
The branch, v3-2-test has been updated
via 0d795606655a67d79c8c3bb2f3676ca7ee28f347 (commit)
from cb98996ed2ac93a0e15838048405772d2043021a (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 0d795606655a67d79c8c3bb2f3676ca7ee28f347
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 9 13:28:30 2008 +0200
Add NetUserAdd example.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/examples/Makefile.in | 8 +++-
.../{dsgetdc/dsgetdc.c => user/user_add.c} | 48 +++++++++++++-------
2 files changed, 38 insertions(+), 18 deletions(-)
copy source/lib/netapi/examples/{dsgetdc/dsgetdc.c => user/user_add.c} (64%)
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/examples/Makefile.in b/source/lib/netapi/examples/Makefile.in
index b60437d..0e074b6 100644
--- a/source/lib/netapi/examples/Makefile.in
+++ b/source/lib/netapi/examples/Makefile.in
@@ -21,7 +21,8 @@ PROGS = bin/getdc at EXEEXT@ \
bin/dsgetdc at EXEEXT@ \
bin/netdomjoin at EXEEXT@ \
bin/netdomjoin-gui at EXEEXT@ \
- bin/getjoinableous at EXEEXT@
+ bin/getjoinableous at EXEEXT@ \
+ bin/user_add at EXEEXT@
all: $(PROGS)
@@ -55,6 +56,7 @@ DSGETDC_OBJ = dsgetdc/dsgetdc.o $(CMDLINE_OBJ)
NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o $(CMDLINE_OBJ)
NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o
GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o $(CMDLINE_OBJ)
+USERADD_OBJ = user/user_add.o $(CMDLINE_OBJ)
bin/getdc at EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ)
@echo Linking $@
@@ -76,6 +78,10 @@ bin/netdomjoin-gui at EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_GUI_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) $(GTK_FLAGS) -o $@ $(NETDOMJOIN_GUI_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(GTK_LIBS)
+bin/user_add at EXEEXT@: $(BINARY_PREREQS) $(USERADD_OBJ)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(USERADD_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
clean:
-rm -f $(PROGS)
-rm -f core */*~ *~ \
diff --git a/source/lib/netapi/examples/dsgetdc/dsgetdc.c b/source/lib/netapi/examples/user/user_add.c
similarity index 64%
copy from source/lib/netapi/examples/dsgetdc/dsgetdc.c
copy to source/lib/netapi/examples/user/user_add.c
index 7c0ec4d..5452f77 100644
--- a/source/lib/netapi/examples/dsgetdc/dsgetdc.c
+++ b/source/lib/netapi/examples/user/user_add.c
@@ -1,6 +1,6 @@
/*
* Unix SMB/CIFS implementation.
- * DsGetDcName query
+ * NetUserAdd query
* Copyright (C) Guenther Deschner 2008
*
* This program is free software; you can redistribute it and/or modify
@@ -31,10 +31,11 @@ int main(int argc, const char **argv)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
-
const char *hostname = NULL;
- const char *domain = NULL;
- struct DOMAIN_CONTROLLER_INFO *info = NULL;
+ const char *username = NULL;
+ const char *password = NULL;
+ struct USER_INFO_1 info1;
+ uint32_t parm_error = 0;
poptContext pc;
int opt;
@@ -50,9 +51,9 @@ int main(int argc, const char **argv)
return status;
}
- pc = poptGetContext("dsgetdc", argc, argv, long_options, 0);
+ pc = poptGetContext("user_add", argc, argv, long_options, 0);
- poptSetOtherOptionHelp(pc, "hostname domainname");
+ poptSetOtherOptionHelp(pc, "hostname username password");
while((opt = poptGetNextOpt(pc)) != -1) {
}
@@ -66,22 +67,35 @@ int main(int argc, const char **argv)
poptPrintHelp(pc, stderr, 0);
goto out;
}
- domain = poptGetArg(pc);
-
- /* DsGetDcName */
+ username = poptGetArg(pc);
- status = DsGetDcName(hostname, domain, NULL, NULL, 0, &info);
+ if (!poptPeekArg(pc)) {
+ poptPrintHelp(pc, stderr, 0);
+ goto out;
+ }
+ password = poptGetArg(pc);
+
+ /* NetUserAdd */
+
+ info1.usri1_name = username;
+ info1.usri1_password = password;
+ info1.usri1_password_age = 0;
+ info1.usri1_priv = 0;
+ info1.usri1_home_dir = NULL;
+ info1.usri1_comment = "User created using Samba NetApi Example code";
+ info1.usri1_flags = 0;
+ info1.usri1_script_path = NULL;
+
+ status = NetUserAdd(hostname,
+ 1,
+ (uint8_t *)&info1,
+ &parm_error);
if (status != 0) {
- printf("DsGetDcName failed with: %s\n",
- libnetapi_errstr(status));
- return status;
+ printf("NetUserAdd failed with: %s\n",
+ libnetapi_get_error_string(ctx, status));
}
- printf("domain %s has name: %s\n",
- info->domain_name, info->domain_controller_name);
-
out:
- NetApiBufferFree(info);
libnetapi_free(ctx);
poptFreeContext(pc);
--
Samba Shared Repository
More information about the samba-cvs
mailing list