The branch, v3-2-test has been updated
       via  a4e3bc2bade8bf74696e1c6ced74da563ff2df7b (commit)
       via  78da087b3a04f25bd0ea3195debf5c46731bac74 (commit)
       via  c098714ac4bac8a7e27be761979a96190b77de1f (commit)
       via  5231a135068a64aedbe2643a9168f2a14c40b139 (commit)
      from  5cb480a664938d93d6cd059c78da9bc78eb58dcb (commit)

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


- Log -----------------------------------------------------------------
commit a4e3bc2bade8bf74696e1c6ced74da563ff2df7b
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Apr 8 02:42:50 2008 +0200

    Restructure inner workings of libnetapi a bit.
    
    Guenther

commit 78da087b3a04f25bd0ea3195debf5c46731bac74
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Apr 8 02:26:21 2008 +0200

    Add libnetapi generated files.
    
    Guenther

commit c098714ac4bac8a7e27be761979a96190b77de1f
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Apr 8 02:25:31 2008 +0200

    Build libnetapi.idl.
    
    Guenther

commit 5231a135068a64aedbe2643a9168f2a14c40b139
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Apr 8 02:25:00 2008 +0200

    Add libnetapi.idl.
    
    Guenther

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

Summary of changes:
 source/Makefile.in                                 |    4 +-
 .../examples/getjoinableous/getjoinableous.c       |    1 +
 source/lib/netapi/getdc.c                          |  142 +-----
 source/lib/netapi/joindomain.c                     |  478 +++++---------------
 source/lib/netapi/libnetapi.c                      |  393 ++++++++++++++++
 source/lib/netapi/libnetapi.h                      |   67 +++
 source/lib/netapi/netapi.h                         |   80 ++--
 source/lib/netapi/serverinfo.c                     |  181 ++------
 source/librpc/gen_ndr/libnetapi.h                  |  140 ++++++
 source/librpc/gen_ndr/ndr_libnetapi.c              |  377 +++++++++++++++
 source/librpc/gen_ndr/ndr_libnetapi.h              |   53 +++
 source/librpc/idl/libnetapi.idl                    |   71 +++
 12 files changed, 1306 insertions(+), 681 deletions(-)
 create mode 100644 source/lib/netapi/libnetapi.c
 create mode 100644 source/lib/netapi/libnetapi.h
 create mode 100644 source/librpc/gen_ndr/libnetapi.h
 create mode 100644 source/librpc/gen_ndr/ndr_libnetapi.c
 create mode 100644 source/librpc/gen_ndr/ndr_libnetapi.h
 create mode 100644 source/librpc/idl/libnetapi.idl


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 6846d80..cc45acd 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -814,6 +814,8 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
             $(DISPLAY_SEC_OBJ) 
 
 LIBNETAPI_OBJ1 = lib/netapi/netapi.o \
+                librpc/gen_ndr/ndr_libnetapi.o \
+                lib/netapi/libnetapi.o \
                 lib/netapi/joindomain.o \
                 lib/netapi/serverinfo.o \
                 lib/netapi/getdc.o
@@ -1163,7 +1165,7 @@ modules: SHOWFLAGS $(MODULES)
 IDL_FILES = lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \
        srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl \
        epmapper.idl messaging.idl xattr.idl misc.idl samr.idl security.idl \
-       dssetup.idl krb5pac.idl ntsvcs.idl
+       dssetup.idl krb5pac.idl ntsvcs.idl libnetapi.idl
 
 idl:
        @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \
diff --git a/source/lib/netapi/examples/getjoinableous/getjoinableous.c 
b/source/lib/netapi/examples/getjoinableous/getjoinableous.c
index 5a3366c..be95198 100644
--- a/source/lib/netapi/examples/getjoinableous/getjoinableous.c
+++ b/source/lib/netapi/examples/getjoinableous/getjoinableous.c
@@ -19,6 +19,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <inttypes.h>
 
 #include <netapi.h>
 
diff --git a/source/lib/netapi/getdc.c b/source/lib/netapi/getdc.c
index 2626eb0..f6a666d 100644
--- a/source/lib/netapi/getdc.c
+++ b/source/lib/netapi/getdc.c
@@ -19,16 +19,16 @@
 
 #include "includes.h"
 
+#include "librpc/gen_ndr/libnetapi.h"
 #include "lib/netapi/netapi.h"
+#include "lib/netapi/libnetapi.h"
 #include "libnet/libnet.h"
 
 /********************************************************************
 ********************************************************************/
 
-static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx,
-                               const char *server_name,
-                               const char *domain_name,
-                               uint8_t **buffer)
+WERROR NetGetDCName_l(struct libnetapi_ctx *ctx,
+                     struct NetGetDCName *r)
 {
        return WERR_NOT_SUPPORTED;
 }
@@ -36,17 +36,15 @@ static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx,
 /********************************************************************
 ********************************************************************/
 
-static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
-                                const char *server_name,
-                                const char *domain_name,
-                                uint8_t **buffer)
+WERROR NetGetDCName_r(struct libnetapi_ctx *ctx,
+                     struct NetGetDCName *r)
 {
        struct cli_state *cli = NULL;
        struct rpc_pipe_client *pipe_cli = NULL;
        NTSTATUS status;
        WERROR werr;
 
-       status = cli_full_connection(&cli, NULL, server_name,
+       status = cli_full_connection(&cli, NULL, r->in.server_name,
                                     NULL, 0,
                                     "IPC$", "IPC",
                                     ctx->username,
@@ -64,12 +62,12 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
        if (!pipe_cli) {
                werr = ntstatus_to_werror(status);
                goto done;
-       };
+       }
 
        status = rpccli_netr_GetDcName(pipe_cli, ctx,
-                                      server_name,
-                                      domain_name,
-                                      (const char **)buffer,
+                                      r->in.server_name,
+                                      r->in.domain_name,
+                                      (const char **)r->out.buffer,
                                       &werr);
  done:
        if (cli) {
@@ -82,59 +80,8 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
 /********************************************************************
 ********************************************************************/
 
-static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx,
-                                    const char *server_name,
-                                    const char *domain_name,
-                                    uint8_t **buffer)
-{
-       if (!server_name || is_myname_or_ipaddr(server_name)) {
-               return NetGetDCNameLocal(ctx,
-                                        server_name,
-                                        domain_name,
-                                        buffer);
-       }
-
-       return NetGetDCNameRemote(ctx,
-                                 server_name,
-                                 domain_name,
-                                 buffer);
-}
-
-/****************************************************************
- NetGetDCName
-****************************************************************/
-
-NET_API_STATUS NetGetDCName(const char *server_name,
-                           const char *domain_name,
-                           uint8_t **buffer)
-{
-       struct libnetapi_ctx *ctx = NULL;
-       NET_API_STATUS status;
-       WERROR werr;
-
-       status = libnetapi_getctx(&ctx);
-       if (status != 0) {
-               return status;
-       }
-
-       werr = libnetapi_NetGetDCName(ctx,
-                                     server_name,
-                                     domain_name,
-                                     buffer);
-       if (!W_ERROR_IS_OK(werr)) {
-               return W_ERROR_V(werr);
-       }
-
-       return NET_API_STATUS_SUCCESS;
-}
-
-/********************************************************************
-********************************************************************/
-
-static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx,
-                                  const char *server_name,
-                                  const char *domain_name,
-                                  uint8_t **buffer)
+WERROR NetGetAnyDCName_l(struct libnetapi_ctx *ctx,
+                        struct NetGetAnyDCName *r)
 {
        return WERR_NOT_SUPPORTED;
 }
@@ -142,17 +89,15 @@ static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx 
*ctx,
 /********************************************************************
 ********************************************************************/
 
-static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx,
-                                   const char *server_name,
-                                   const char *domain_name,
-                                   uint8_t **buffer)
+WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
+                        struct NetGetAnyDCName *r)
 {
        struct cli_state *cli = NULL;
        struct rpc_pipe_client *pipe_cli = NULL;
        NTSTATUS status;
        WERROR werr;
 
-       status = cli_full_connection(&cli, NULL, server_name,
+       status = cli_full_connection(&cli, NULL, r->in.server_name,
                                     NULL, 0,
                                     "IPC$", "IPC",
                                     ctx->username,
@@ -173,9 +118,9 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx 
*ctx,
        };
 
        status = rpccli_netr_GetAnyDCName(pipe_cli, ctx,
-                                         server_name,
-                                         domain_name,
-                                         (const char **)buffer,
+                                         r->in.server_name,
+                                         r->in.domain_name,
+                                         (const char **)r->out.buffer,
                                          &werr);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
@@ -188,52 +133,3 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx 
*ctx,
        return werr;
 
 }
-
-/********************************************************************
-********************************************************************/
-
-static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx,
-                                       const char *server_name,
-                                       const char *domain_name,
-                                       uint8_t **buffer)
-{
-       if (!server_name || is_myname_or_ipaddr(server_name)) {
-               return NetGetAnyDCNameLocal(ctx,
-                                           server_name,
-                                           domain_name,
-                                           buffer);
-       }
-
-       return NetGetAnyDCNameRemote(ctx,
-                                    server_name,
-                                    domain_name,
-                                    buffer);
-}
-
-/****************************************************************
- NetGetAnyDCName
-****************************************************************/
-
-NET_API_STATUS NetGetAnyDCName(const char *server_name,
-                              const char *domain_name,
-                              uint8_t **buffer)
-{
-       struct libnetapi_ctx *ctx = NULL;
-       NET_API_STATUS status;
-       WERROR werr;
-
-       status = libnetapi_getctx(&ctx);
-       if (status != 0) {
-               return status;
-       }
-
-       werr = libnetapi_NetGetAnyDCName(ctx,
-                                        server_name,
-                                        domain_name,
-                                        buffer);
-       if (!W_ERROR_IS_OK(werr)) {
-               return W_ERROR_V(werr);
-       }
-
-       return NET_API_STATUS_SUCCESS;
-}
diff --git a/source/lib/netapi/joindomain.c b/source/lib/netapi/joindomain.c
index ed8327e..468360f 100644
--- a/source/lib/netapi/joindomain.c
+++ b/source/lib/netapi/joindomain.c
@@ -19,75 +19,72 @@
 
 #include "includes.h"
 
+#include "librpc/gen_ndr/libnetapi.h"
 #include "lib/netapi/netapi.h"
+#include "lib/netapi/libnetapi.h"
 #include "libnet/libnet.h"
 
 /****************************************************************
 ****************************************************************/
 
-static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
-                                const char *server_name,
-                                const char *domain_name,
-                                const char *account_ou,
-                                const char *Account,
-                                const char *password,
-                                uint32_t join_flags)
+WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx,
+                      struct NetJoinDomain *r)
 {
-       struct libnet_JoinCtx *r = NULL;
+       struct libnet_JoinCtx *j = NULL;
        WERROR werr;
 
-       if (!domain_name) {
+       if (!r->in.domain) {
                return WERR_INVALID_PARAM;
        }
 
-       werr = libnet_init_JoinCtx(mem_ctx, &r);
+       werr = libnet_init_JoinCtx(mem_ctx, &j);
        W_ERROR_NOT_OK_RETURN(werr);
 
-       r->in.domain_name = talloc_strdup(mem_ctx, domain_name);
-       W_ERROR_HAVE_NO_MEMORY(r->in.domain_name);
+       j->in.domain_name = talloc_strdup(mem_ctx, r->in.domain);
+       W_ERROR_HAVE_NO_MEMORY(j->in.domain_name);
 
-       if (join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
+       if (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
                NTSTATUS status;
                struct netr_DsRGetDCNameInfo *info = NULL;
                uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
                                 DS_WRITABLE_REQUIRED |
                                 DS_RETURN_DNS_NAME;
-               status = dsgetdcname(mem_ctx, domain_name,
+               status = dsgetdcname(mem_ctx, r->in.domain,
                                     NULL, NULL, flags, &info);
                if (!NT_STATUS_IS_OK(status)) {
                        libnetapi_set_error_string(mem_ctx,
                                "%s", get_friendly_nt_error_msg(status));
                        return ntstatus_to_werror(status);
                }
-               r->in.dc_name = talloc_strdup(mem_ctx,
+               j->in.dc_name = talloc_strdup(mem_ctx,
                                              info->dc_unc);
-               W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
+               W_ERROR_HAVE_NO_MEMORY(j->in.dc_name);
        }
 
-       if (account_ou) {
-               r->in.account_ou = talloc_strdup(mem_ctx, account_ou);
-               W_ERROR_HAVE_NO_MEMORY(r->in.account_ou);
+       if (r->in.account_ou) {
+               j->in.account_ou = talloc_strdup(mem_ctx, r->in.account_ou);
+               W_ERROR_HAVE_NO_MEMORY(j->in.account_ou);
        }
 
-       if (Account) {
-               r->in.admin_account = talloc_strdup(mem_ctx, Account);
-               W_ERROR_HAVE_NO_MEMORY(r->in.admin_account);
+       if (r->in.account) {
+               j->in.admin_account = talloc_strdup(mem_ctx, r->in.account);
+               W_ERROR_HAVE_NO_MEMORY(j->in.admin_account);
        }
 
-       if (password) {
-               r->in.admin_password = talloc_strdup(mem_ctx, password);
-               W_ERROR_HAVE_NO_MEMORY(r->in.admin_password);
+       if (r->in.password) {
+               j->in.admin_password = talloc_strdup(mem_ctx, r->in.password);
+               W_ERROR_HAVE_NO_MEMORY(j->in.admin_password);
        }
 
-       r->in.join_flags = join_flags;
-       r->in.modify_config = true;
-       r->in.debug = true;
+       j->in.join_flags = r->in.join_flags;
+       j->in.modify_config = true;
+       j->in.debug = true;
 
-       werr = libnet_Join(mem_ctx, r);
-       if (!W_ERROR_IS_OK(werr) && r->out.error_string) {
-               libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string);
+       werr = libnet_Join(mem_ctx, j);
+       if (!W_ERROR_IS_OK(werr) && j->out.error_string) {
+               libnetapi_set_error_string(mem_ctx, "%s", j->out.error_string);
        }
-       TALLOC_FREE(r);
+       TALLOC_FREE(j);
 
        return werr;
 }
@@ -95,13 +92,8 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx 
*mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
-                                 const char *server_name,
-                                 const char *domain_name,
-                                 const char *account_ou,
-                                 const char *Account,
-                                 const char *password,
-                                 uint32_t join_flags)
+WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
+                      struct NetJoinDomain *r)
 {
        struct cli_state *cli = NULL;
        struct rpc_pipe_client *pipe_cli = NULL;
@@ -110,7 +102,7 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
        WERROR werr;
        unsigned int old_timeout = 0;
 
-       status = cli_full_connection(&cli, NULL, server_name,
+       status = cli_full_connection(&cli, NULL, r->in.server,
                                     NULL, 0,
                                     "IPC$", "IPC",
                                     ctx->username,
@@ -130,20 +122,23 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx 
*ctx,
                goto done;
        }
 
-       if (password) {
+       if (r->in.password) {
                encode_wkssvc_join_password_buffer(ctx,
-                                                  password,
+                                                  r->in.password,
                                                   &cli->user_session_key,
                                                   &encrypted_password);
        }
 
-       old_timeout = cli_set_timeout(cli, 60000);
+       old_timeout = cli_set_timeout(cli, 600000);
 
        status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, ctx,
-                                              server_name, domain_name,
-                                              account_ou, Account,
+                                              r->in.server,
+                                              r->in.domain,
+                                              r->in.account_ou,
+                                              r->in.account,
                                               encrypted_password,
-                                              join_flags, &werr);
+                                              r->in.join_flags,
+                                              &werr);
        if (!NT_STATUS_IS_OK(status)) {
                werr = ntstatus_to_werror(status);
                goto done;
@@ -151,92 +146,21 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx 
*ctx,
 
  done:
        if (cli) {
-               cli_set_timeout(cli, old_timeout);
+               if (old_timeout) {
+                       cli_set_timeout(cli, old_timeout);
+               }
                cli_shutdown(cli);
        }
 
        return werr;
 }
-
-/****************************************************************
-****************************************************************/
-
-static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx,
-                                     const char *server_name,
-                                     const char *domain_name,
-                                     const char *account_ou,
-                                     const char *Account,
-                                     const char *password,
-                                     uint32_t join_flags)
-{
-       if (!domain_name) {
-               return WERR_INVALID_PARAM;
-       }
-
-       if (!server_name || is_myname_or_ipaddr(server_name)) {
-
-               return NetJoinDomainLocal(ctx,
-                                         server_name,
-                                         domain_name,
-                                         account_ou,
-                                         Account,
-                                         password,
-                                         join_flags);
-       }
-
-       return NetJoinDomainRemote(ctx,
-                                  server_name,
-                                  domain_name,
-                                  account_ou,
-                                  Account,
-                                  password,
-                                  join_flags);
-}
-
 /****************************************************************
- NetJoinDomain
 ****************************************************************/
 
-NET_API_STATUS NetJoinDomain(const char *server_name,
-                            const char *domain_name,
-                            const char *account_ou,
-                            const char *Account,
-                            const char *password,
-                            uint32_t join_flags)
+WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
+                        struct NetUnjoinDomain *r)
 {
-       struct libnetapi_ctx *ctx = NULL;
-       NET_API_STATUS status;
-       WERROR werr;
-
-       status = libnetapi_getctx(&ctx);
-       if (status != 0) {
-               return status;
-       }
-
-       werr = libnetapi_NetJoinDomain(ctx,
-                                      server_name,
-                                      domain_name,
-                                      account_ou,
-                                      Account,
-                                      password,
-                                      join_flags);
-       if (!W_ERROR_IS_OK(werr)) {
-               return W_ERROR_V(werr);
-       }
-
-       return NET_API_STATUS_SUCCESS;
-}
-
-/****************************************************************
-****************************************************************/
-
-static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx,
-                                  const char *server_name,


-- 
Samba Shared Repository

Reply via email to