[SCM] Samba Shared Repository - branch v3-5-test updated

Günther Deschner gd at samba.org
Fri Oct 16 08:11:07 MDT 2009


The branch, v3-5-test has been updated
       via  f2b9430... nsswitch: increase libwbclient version after adding wbcChangeTrustCredentials().
       via  823a1c4... s4-smbtorture: extend netr_LogonControl test in RPC-NETLOGON.
       via  7cebe58... s3-netlogon: Fix _netr_ServerPasswordSet2 cleartext blob handling.
       via  227558f... s4-smbtorture: test wbcLookupUserSids in WINBIND-WBCLIENT as well.
       via  5e295ad... s4-smbtorture: test wbcGuidToString and friends as well in WINBIND-WBCLIENT.
       via  f44ee3f... s3-libnetapi: add nltest tool.
       via  1b51be2... s3-libnetapi: add I_NetLogonControl{2} example code.
       via  e3b9268... s3-libnetapi: add I_NetLogonControl{2} to public headers.
       via  48678f4... s3-libnetapi: fill in I_NetLogonControl{2}_r.
       via  3f7a17c... s3-libnetapi: add I_NetLogonControl{2} skeleton.
       via  4df0e57... s3-libnetapi: add I_NetLogonControl{2} to IDL.
       via  8dcf3e3... s3-selftest: enable WINBIND-WBCLIENT against s3.
       via  27e64f5... s4-smbtorture: add very basic libwbclient testsuite.
       via  c2281ae... s3-net: fix build warning (missing default in switch).
      from  11a6d88... s3:packaging: Fix building RHEL packages.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-test


- Log -----------------------------------------------------------------
commit f2b94302ba7b30703b2edbdb5272582cff03fff9
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 16:07:31 2009 +0200

    nsswitch: increase libwbclient version after adding wbcChangeTrustCredentials().
    
    Guenther
    (cherry picked from commit 20c07674f6c0b9423c13b9876dbe4d12f86e0d72)

commit 823a1c4024003aa69ae7c918dfa3c0fcec12498e
Author: Günther Deschner <gd at samba.org>
Date:   Wed Oct 14 11:58:21 2009 +0200

    s4-smbtorture: extend netr_LogonControl test in RPC-NETLOGON.
    
    Guenther
    (cherry picked from commit 22276961c398da5997402f09f7443d76f621d3ec)

commit 7cebe583a305de03dd53df31de566cb3dea1c0f8
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 12:09:55 2009 +0200

    s3-netlogon: Fix _netr_ServerPasswordSet2 cleartext blob handling.
    
    Following Andrew's advice, let's straight md4 the plaintext blob and avoid
    trying to get a paintext string out of the input the client sends.
    
    Guenther
    (cherry picked from commit 8267564e1c52b3d335bf892ab71963bfb0e6e7e8)

commit 227558fb3bbe037b812f5cf202701f9bf28af919
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 14:51:49 2009 +0200

    s4-smbtorture: test wbcLookupUserSids in WINBIND-WBCLIENT as well.
    
    Guenther
    (cherry picked from commit c2966a0766998b732c190860879c001d6140863e)

commit 5e295ada507a50a135759d2c70cbb8195546d2b7
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 13:38:57 2009 +0200

    s4-smbtorture: test wbcGuidToString and friends as well in WINBIND-WBCLIENT.
    
    Guenther
    (cherry picked from commit 246597cb0d8d62c702841dfbb3fa257fc2da70da)

commit f44ee3f5297470fd319204c1b6aef6e8398921f9
Author: Günther Deschner <gd at samba.org>
Date:   Thu Oct 15 01:04:27 2009 +0200

    s3-libnetapi: add nltest tool.
    
    Guenther
    (cherry picked from commit a85799d5db9e8dcbb6f12299dc5ff31485c0617f)

commit 1b51be2a75420c1ac71e25420c9a6a950bd7ecd0
Author: Günther Deschner <gd at samba.org>
Date:   Tue Oct 13 16:47:32 2009 +0200

    s3-libnetapi: add I_NetLogonControl{2} example code.
    
    Guenther
    (cherry picked from commit ca19ffde80df80aa8a58b0ad141e712f3f60ad81)

commit e3b92680b6ad378a2ae286fe446d1a0dd5a7140b
Author: Günther Deschner <gd at samba.org>
Date:   Tue Oct 13 16:46:54 2009 +0200

    s3-libnetapi: add I_NetLogonControl{2} to public headers.
    
    Guenther
    (cherry picked from commit d308aa3de86f4d5d66d4f618fb3dd3fcf65a3992)

commit 48678f46a0f681bf23f9d93c6c0709e377f210e9
Author: Günther Deschner <gd at samba.org>
Date:   Tue Oct 13 16:03:58 2009 +0200

    s3-libnetapi: fill in I_NetLogonControl{2}_r.
    
    Guenther
    (cherry picked from commit e31c2c7eb1f015774ad0adb3af8110f467461878)

commit 3f7a17c57b67a452c337316884de3a7cd250c66a
Author: Günther Deschner <gd at samba.org>
Date:   Tue Oct 13 15:47:56 2009 +0200

    s3-libnetapi: add I_NetLogonControl{2} skeleton.
    
    Guenther
    (cherry picked from commit e8e1d609411c37b5839e5b50b95f07691370c247)

commit 4df0e57ad0c66f99c4ffae4a35a8452cd49a3907
Author: Günther Deschner <gd at samba.org>
Date:   Tue Oct 13 15:39:27 2009 +0200

    s3-libnetapi: add I_NetLogonControl{2} to IDL.
    
    Guenther
    (cherry picked from commit 8bd4378ff8ddc81710575a21ca7713195a105b52)

commit 8dcf3e3009073cdf45b0736671bd4ecfe0baabfd
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 01:58:49 2009 +0200

    s3-selftest: enable WINBIND-WBCLIENT against s3.
    
    Guenther
    (cherry picked from commit 3f80b06d9ed9d1aabb56168ccee90d7d945de8ed)

commit 27e64f5fe99ff49e2153c0046399d1c58cc36b56
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 00:33:38 2009 +0200

    s4-smbtorture: add very basic libwbclient testsuite.
    
    Guenther
    (cherry picked from commit 612deb2699c87fc05b98290e1791493603e7b686)

commit c2281ae03020144da20e49cfd2cde09ee542cf34
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 16 01:59:08 2009 +0200

    s3-net: fix build warning (missing default in switch).
    
    Guenther
    (cherry picked from commit 8b247f35389a899c805d018adb92f372e562a378)

-----------------------------------------------------------------------

Summary of changes:
 nsswitch/libwbclient/tests/wbclient.c              |  289 ++++++++++++++++++++
 nsswitch/libwbclient/wbclient.h                    |    3 +-
 source3/Makefile.in                                |    3 +-
 source3/lib/netapi/examples/Makefile.in            |   20 ++-
 .../netapi/examples/netlogon/netlogon_control.c    |  143 ++++++++++
 .../netapi/examples/netlogon/netlogon_control2.c   |  147 ++++++++++
 source3/lib/netapi/examples/netlogon/nltest.c      |  251 +++++++++++++++++
 source3/lib/netapi/libnetapi.c                     |   94 +++++++
 source3/lib/netapi/libnetapi.h                     |   17 ++
 source3/lib/netapi/netapi.h                        |   92 ++++++-
 source3/lib/netapi/netlogon.c                      |  240 ++++++++++++++++
 source3/librpc/gen_ndr/libnetapi.h                 |   58 ++++
 source3/librpc/gen_ndr/ndr_libnetapi.c             |   70 +++++
 source3/librpc/gen_ndr/ndr_libnetapi.h             |   12 +-
 source3/librpc/idl/libnetapi.idl                   |   49 ++++
 source3/rpc_server/srv_netlog_nt.c                 |    5 +-
 source3/script/tests/test_posix_s3.sh              |    4 +-
 source3/utils/net_rpc_join.c                       |    4 +
 source4/torture/rpc/netlogon.c                     |  112 ++++++++-
 source4/torture/winbind/config.mk                  |    4 +-
 source4/torture/winbind/winbind.c                  |    1 +
 21 files changed, 1606 insertions(+), 12 deletions(-)
 create mode 100644 nsswitch/libwbclient/tests/wbclient.c
 create mode 100644 source3/lib/netapi/examples/netlogon/netlogon_control.c
 create mode 100644 source3/lib/netapi/examples/netlogon/netlogon_control2.c
 create mode 100644 source3/lib/netapi/examples/netlogon/nltest.c
 create mode 100644 source3/lib/netapi/netlogon.c


Changeset truncated at 500 lines:

diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
new file mode 100644
index 0000000..5a55a43
--- /dev/null
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -0,0 +1,289 @@
+/*
+   Unix SMB/CIFS implementation.
+   SMB torture tester
+   Copyright (C) Guenther Deschner 2009
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "nsswitch/libwbclient/wbclient.h"
+#include "torture/smbtorture.h"
+#include "torture/winbind/proto.h"
+
+#define WBC_ERROR_EQUAL(x,y) (x == y)
+
+#define torture_assert_wbc_equal(torture_ctx, got, expected, cmt) \
+	do { wbcErr __got = got, __expected = expected; \
+	if (!WBC_ERROR_EQUAL(__got, __expected)) { \
+		torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", wbcErrorString(__got), wbcErrorString(__expected), cmt); \
+		return false; \
+	} \
+	} while (0)
+
+#define torture_assert_wbc_ok(torture_ctx,expr,cmt) \
+		torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt)
+
+static bool test_wbc_ping(struct torture_context *tctx)
+{
+	torture_assert_wbc_ok(tctx, wbcPing(),
+		"wbcPing failed");
+
+	return true;
+}
+
+static bool test_wbc_library_details(struct torture_context *tctx)
+{
+	struct wbcLibraryDetails *details;
+
+	torture_assert_wbc_ok(tctx, wbcLibraryDetails(&details),
+		"wbcLibraryDetails failed");
+	torture_assert(tctx, details,
+		"wbcLibraryDetails returned NULL pointer");
+
+	wbcFreeMemory(details);
+
+	return true;
+}
+
+static bool test_wbc_interface_details(struct torture_context *tctx)
+{
+	struct wbcInterfaceDetails *details;
+
+	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+		"wbcInterfaceDetails failed");
+	torture_assert(tctx, details,
+		"wbcInterfaceDetails returned NULL pointer");
+
+	wbcFreeMemory(details);
+
+	return true;
+}
+
+static bool test_wbc_sidtypestring(struct torture_context *tctx)
+{
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_USE_NONE),
+				 "SID_NONE", "SID_NONE failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_USER),
+				 "SID_USER", "SID_USER failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_DOM_GRP),
+				 "SID_DOM_GROUP", "SID_DOM_GROUP failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_DOMAIN),
+				 "SID_DOMAIN", "SID_DOMAIN failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_ALIAS),
+				 "SID_ALIAS", "SID_ALIAS failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_WKN_GRP),
+				 "SID_WKN_GROUP", "SID_WKN_GROUP failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_DELETED),
+				 "SID_DELETED", "SID_DELETED failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_INVALID),
+				 "SID_INVALID", "SID_INVALID failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_UNKNOWN),
+				 "SID_UNKNOWN", "SID_UNKNOWN failed");
+	torture_assert_str_equal(tctx, wbcSidTypeString(WBC_SID_NAME_COMPUTER),
+				 "SID_COMPUTER", "SID_COMPUTER failed");
+	return true;
+}
+
+static bool test_wbc_sidtostring(struct torture_context *tctx)
+{
+	struct wbcDomainSid sid;
+	const char *sid_string = "S-1-5-32";
+	char *sid_string2;
+
+	torture_assert_wbc_ok(tctx, wbcStringToSid(sid_string, &sid),
+		"wbcStringToSid failed");
+	torture_assert_wbc_ok(tctx, wbcSidToString(&sid, &sid_string2),
+		"wbcSidToString failed");
+	torture_assert_str_equal(tctx, sid_string, sid_string2,
+		"sid strings differ");
+
+	return true;
+}
+
+static bool test_wbc_guidtostring(struct torture_context *tctx)
+{
+	struct wbcGuid guid;
+	const char *guid_string = "f7cf07b4-1487-45c7-824d-8b18cc580811";
+	char *guid_string2;
+
+	torture_assert_wbc_ok(tctx, wbcStringToGuid(guid_string, &guid),
+		"wbcStringToGuid failed");
+	torture_assert_wbc_ok(tctx, wbcGuidToString(&guid, &guid_string2),
+		"wbcGuidToString failed");
+	torture_assert_str_equal(tctx, guid_string, guid_string2,
+		"guid strings differ");
+
+	return true;
+}
+
+static bool test_wbc_domain_info(struct torture_context *tctx)
+{
+	const char *domain_name = NULL;
+	struct wbcDomainInfo *info;
+	struct wbcInterfaceDetails *details;
+
+	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+		"wbcInterfaceDetails failed");
+
+	domain_name = talloc_strdup(tctx, details->netbios_domain);
+	wbcFreeMemory(details);
+
+	torture_assert_wbc_ok(tctx, wbcDomainInfo(domain_name, &info),
+		"wbcDomainInfo failed");
+	torture_assert(tctx, info,
+		"wbcDomainInfo returned NULL pointer");
+
+	return true;
+}
+
+static bool test_wbc_users(struct torture_context *tctx)
+{
+	const char *domain_name = NULL;
+	uint32_t num_users;
+	const char **users;
+	int i;
+	struct wbcInterfaceDetails *details;
+
+	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+		"wbcInterfaceDetails failed");
+
+	domain_name = talloc_strdup(tctx, details->netbios_domain);
+	wbcFreeMemory(details);
+
+	torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users),
+		"wbcListUsers failed");
+	torture_assert(tctx, !(num_users > 0 && !users),
+		"wbcListUsers returned invalid results");
+
+	for (i=0; i < MIN(num_users,100); i++) {
+
+		struct wbcDomainSid sid, *sids;
+		enum wbcSidType name_type;
+		char *domain;
+		char *name;
+		uint32_t num_sids;
+
+		torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, users[i], &sid, &name_type),
+			"wbcLookupName failed");
+		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER,
+			"wbcLookupName expected WBC_SID_NAME_USER");
+		torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
+			"wbcLookupSid failed");
+		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER,
+			"wbcLookupSid expected WBC_SID_NAME_USER");
+		torture_assert(tctx, name,
+			"wbcLookupSid returned no name");
+		torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids),
+			"wbcLookupUserSids failed");
+	}
+
+	return true;
+}
+
+static bool test_wbc_groups(struct torture_context *tctx)
+{
+	const char *domain_name = NULL;
+	uint32_t num_groups;
+	const char **groups;
+	int i;
+	struct wbcInterfaceDetails *details;
+
+	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+		"wbcInterfaceDetails failed");
+
+	domain_name = talloc_strdup(tctx, details->netbios_domain);
+	wbcFreeMemory(details);
+
+	torture_assert_wbc_ok(tctx, wbcListGroups(domain_name, &num_groups, &groups),
+		"wbcListGroups failed");
+	torture_assert(tctx, !(num_groups > 0 && !groups),
+		"wbcListGroups returned invalid results");
+
+	for (i=0; i < MIN(num_groups,100); i++) {
+
+		struct wbcDomainSid sid;
+		enum wbcSidType name_type;
+		char *domain;
+		char *name;
+
+		torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, groups[i], &sid, &name_type),
+			"wbcLookupName failed");
+		torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
+			"wbcLookupSid failed");
+		torture_assert(tctx, name,
+			"wbcLookupSid returned no name");
+	}
+
+	return true;
+}
+
+static bool test_wbc_trusts(struct torture_context *tctx)
+{
+	struct wbcDomainInfo *domains;
+	size_t num_domains;
+	int i;
+
+	torture_assert_wbc_ok(tctx, wbcListTrusts(&domains, &num_domains),
+		"wbcListTrusts failed");
+	torture_assert(tctx, !(num_domains > 0 && !domains),
+		"wbcListTrusts returned invalid results");
+
+	for (i=0; i < MIN(num_domains,100); i++) {
+
+		struct wbcAuthErrorInfo *error;
+		/*
+		struct wbcDomainSid sid;
+		enum wbcSidType name_type;
+		char *domain;
+		char *name;
+		*/
+		torture_assert_wbc_ok(tctx, wbcCheckTrustCredentials(domains[i].short_name, &error),
+			"wbcCheckTrustCredentials failed");
+		/*
+		torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type),
+			"wbcLookupName failed");
+		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
+			"wbcLookupName expected WBC_SID_NAME_DOMAIN");
+		torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
+			"wbcLookupSid failed");
+		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
+			"wbcLookupSid expected WBC_SID_NAME_DOMAIN");
+		torture_assert(tctx, name,
+			"wbcLookupSid returned no name");
+		*/
+	}
+
+	return true;
+}
+
+
+
+struct torture_suite *torture_wbclient(void)
+{
+	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WBCLIENT");
+
+	torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping);
+	torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details);
+	torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details);
+	torture_suite_add_simple_test(suite, "wbcSidTypeString", test_wbc_sidtypestring);
+	torture_suite_add_simple_test(suite, "wbcSidToString", test_wbc_sidtostring);
+	torture_suite_add_simple_test(suite, "wbcGuidToString", test_wbc_guidtostring);
+	torture_suite_add_simple_test(suite, "wbcDomainInfo", test_wbc_domain_info);
+	torture_suite_add_simple_test(suite, "wbcListUsers", test_wbc_users);
+	torture_suite_add_simple_test(suite, "wbcListGroups", test_wbc_groups);
+	torture_suite_add_simple_test(suite, "wbcListTrusts", test_wbc_trusts);
+
+	return suite;
+}
diff --git a/nsswitch/libwbclient/wbclient.h b/nsswitch/libwbclient/wbclient.h
index ecc1f7f..1efd90f 100644
--- a/nsswitch/libwbclient/wbclient.h
+++ b/nsswitch/libwbclient/wbclient.h
@@ -63,9 +63,10 @@ const char *wbcErrorString(wbcErr error);
  *  0.3: Added wbcGetpwsid()
  *	 Added wbcGetSidAliases()
  *  0.4: Added wbcSidTypeString()
+ *  0.5: Added wbcChangeTrustCredentials()
  **/
 #define WBCLIENT_MAJOR_VERSION 0
-#define WBCLIENT_MINOR_VERSION 4
+#define WBCLIENT_MINOR_VERSION 5
 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
 struct wbcLibraryDetails {
 	uint16_t major_version;
diff --git a/source3/Makefile.in b/source3/Makefile.in
index d12c991..4dbc8cd 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -2156,7 +2156,8 @@ LIBNETAPI_OBJ0 = lib/netapi/netapi.o \
 		 lib/netapi/sid.o \
 		 lib/netapi/share.o \
 		 lib/netapi/file.o \
-		 lib/netapi/shutdown.o
+		 lib/netapi/shutdown.o \
+		 lib/netapi/netlogon.o
 
 LIBNETAPI_OBJ  = $(LIBNETAPI_OBJ0) $(LIBNET_OBJ) \
 		 $(LIBSMBCONF_OBJ) \
diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in
index 2a99f57..4e921b6 100644
--- a/source3/lib/netapi/examples/Makefile.in
+++ b/source3/lib/netapi/examples/Makefile.in
@@ -65,7 +65,10 @@ PROGS = bin/getdc at EXEEXT@ \
 	bin/file_getinfo at EXEEXT@ \
 	bin/file_enum at EXEEXT@ \
 	bin/shutdown_init at EXEEXT@ \
-	bin/shutdown_abort at EXEEXT@
+	bin/shutdown_abort at EXEEXT@ \
+	bin/netlogon_control at EXEEXT@ \
+	bin/netlogon_control2 at EXEEXT@ \
+	bin/nltest at EXEEXT@
 
 all: $(PROGS)
 
@@ -143,6 +146,9 @@ FILEGETINFO_OBJ = file/file_getinfo.o $(CMDLINE_OBJ)
 FILEENUM_OBJ = file/file_enum.o $(CMDLINE_OBJ)
 SHUTDOWNINIT_OBJ = shutdown/shutdown_init.o $(CMDLINE_OBJ)
 SHUTDOWNABORT_OBJ = shutdown/shutdown_abort.o $(CMDLINE_OBJ)
+NETLOGONCONTROL_OBJ = netlogon/netlogon_control.o $(CMDLINE_OBJ)
+NETLOGONCONTROL2_OBJ = netlogon/netlogon_control2.o $(CMDLINE_OBJ)
+NLTEST_OBJ = netlogon/nltest.o $(CMDLINE_OBJ)
 
 bin/getdc at EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ)
 	@echo Linking $@
@@ -340,6 +346,18 @@ bin/shutdown_abort at EXEEXT@: $(BINARY_PREREQS) $(SHUTDOWNABORT_OBJ)
 	@echo Linking $@
 	@$(CC) $(CCFLAGS) -o $@ $(SHUTDOWNABORT_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
 
+bin/netlogon_control at EXEEXT@: $(BINARY_PREREQS) $(NETLOGONCONTROL_OBJ)
+	@echo Linking $@
+	@$(CC) $(CCFLAGS) -o $@ $(NETLOGONCONTROL_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
+bin/netlogon_control2 at EXEEXT@: $(BINARY_PREREQS) $(NETLOGONCONTROL2_OBJ)
+	@echo Linking $@
+	@$(CC) $(CCFLAGS) -o $@ $(NETLOGONCONTROL2_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
+bin/nltest at EXEEXT@: $(BINARY_PREREQS) $(NLTEST_OBJ)
+	@echo Linking $@
+	@$(CC) $(CCFLAGS) -o $@ $(NLTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
 clean:
 	-rm -f $(PROGS)
 	-rm -f core */*~ *~ \
diff --git a/source3/lib/netapi/examples/netlogon/netlogon_control.c b/source3/lib/netapi/examples/netlogon/netlogon_control.c
new file mode 100644
index 0000000..34361cd
--- /dev/null
+++ b/source3/lib/netapi/examples/netlogon/netlogon_control.c
@@ -0,0 +1,143 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  I_NetLogonControl query
+ *  Copyright (C) Guenther Deschner 2009
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netapi.h>
+
+#include "common.h"
+
+int main(int argc, const char **argv)
+{
+	NET_API_STATUS status;
+	struct libnetapi_ctx *ctx = NULL;
+	const char *hostname = NULL;
+	uint32_t function_code = NETLOGON_CONTROL_QUERY;
+	uint32_t level = 1;
+	uint8_t *buffer = NULL;
+	struct NETLOGON_INFO_1 *i1 = NULL;
+	struct NETLOGON_INFO_2 *i2 = NULL;
+	struct NETLOGON_INFO_3 *i3 = NULL;
+	struct NETLOGON_INFO_4 *i4 = NULL;
+
+	poptContext pc;
+	int opt;
+
+	struct poptOption long_options[] = {
+		POPT_AUTOHELP
+		POPT_COMMON_LIBNETAPI_EXAMPLES
+		POPT_TABLEEND
+	};
+
+	status = libnetapi_init(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	pc = poptGetContext("netlogon_control", argc, argv, long_options, 0);
+
+	poptSetOtherOptionHelp(pc, "hostname");
+	while((opt = poptGetNextOpt(pc)) != -1) {
+	}
+
+	if (!poptPeekArg(pc)) {
+		poptPrintHelp(pc, stderr, 0);
+		goto out;
+	}
+	hostname = poptGetArg(pc);
+
+	if (poptPeekArg(pc)) {
+		function_code = atoi(poptGetArg(pc));
+	}
+
+	if (poptPeekArg(pc)) {
+		level = atoi(poptGetArg(pc));
+	}
+
+	/* I_NetLogonControl */
+
+	status = I_NetLogonControl(hostname,
+				   function_code,
+				   level,
+				   &buffer);
+	if (status != 0) {
+		printf("I_NetLogonControl failed with: %s\n",
+			libnetapi_get_error_string(ctx, status));
+		goto out;
+	}
+
+	if (!buffer) {
+		goto out;
+	}
+
+	switch (level) {
+	case 1:
+		i1 = (struct NETLOGON_INFO_1 *)buffer;
+
+		printf("Flags: %x\n", i1->netlog1_flags);
+		printf("Connection Status Status = %d 0x%x %s\n",
+			i1->netlog1_pdc_connection_status,
+			i1->netlog1_pdc_connection_status,
+			libnetapi_errstr(i1->netlog1_pdc_connection_status));
+
+		break;
+	case 2:
+		i2 = (struct NETLOGON_INFO_2 *)buffer;
+
+		printf("Flags: %x\n", i2->netlog2_flags);
+		printf("Trusted DC Name %s\n", i2->netlog2_trusted_dc_name);
+		printf("Trusted DC Connection Status Status = %d 0x%x %s\n",
+			i2->netlog2_tc_connection_status,
+			i2->netlog2_tc_connection_status,
+			libnetapi_errstr(i2->netlog2_tc_connection_status));
+		printf("Trust Verification Status Status = %d 0x%x %s\n",
+			i2->netlog2_pdc_connection_status,
+			i2->netlog2_pdc_connection_status,
+			libnetapi_errstr(i2->netlog2_pdc_connection_status));
+
+		break;
+	case 3:
+		i3 = (struct NETLOGON_INFO_3 *)buffer;
+
+		printf("Flags: %x\n", i3->netlog1_flags);
+		printf("Logon Attempts: %d\n", i3->netlog3_logon_attempts);
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list