r1919: paasword change basicly works now:-)
authorStefan Metzmacher <metze@samba.org>
Thu, 19 Aug 2004 13:32:06 +0000 (13:32 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:58:11 +0000 (12:58 -0500)
but we need to find the real pdc for the users domain
and fallback to other levels

metze

source/libnet/libnet.h
source/libnet/libnet_passwd.c
source/libnet/libnet_rpc.c
source/utils/net/net_password.c

index 65dba4ff78481df2939bb4ccc296924a105e2a0d..0a96e6c530ce5e662b49c54779bd9def34048337 100644 (file)
@@ -25,6 +25,11 @@ struct libnet_context {
         * a client env context
         * a user env context
         */
+       struct {
+               const char *account_name;
+               const char *domain_name;
+               const char *password;
+       } user;
 };
 
 /* struct and enum for connecting to a dcerpc inferface */
index ea61a457baeead1bee577374fdf9158ea1d41b57..cdb5160a922b4fbe319d89d404fac1e5475de595 100644 (file)
@@ -109,11 +109,11 @@ static NTSTATUS libnet_ChangePassword_generic(struct libnet_context *ctx, TALLOC
        NTSTATUS status;
        union libnet_ChangePassword r2;
 
-       r2.generic.level        = LIBNET_CHANGE_PASSWORD_RPC;
-       r2.rpc.in.account_name  = NULL;
-       r2.rpc.in.domain_name   = NULL;
-       r2.rpc.in.oldpassword   = NULL;
-       r2.rpc.in.newpassword   = NULL;
+       r2.rpc.level            = LIBNET_CHANGE_PASSWORD_RPC;
+       r2.rpc.in.account_name  = r->generic.in.account_name;
+       r2.rpc.in.domain_name   = r->generic.in.domain_name;
+       r2.rpc.in.oldpassword   = r->generic.in.oldpassword;
+       r2.rpc.in.newpassword   = r->generic.in.newpassword;
 
        status = libnet_ChangePassword(ctx, mem_ctx, &r2);
 
index 0ab07fa4a5d403ab32e9db6c6bdb580f91d93a46..c76498d0bb8a064b1dc503c908fbc2f6d573e161 100644 (file)
 
 #include "includes.h"
 
+/* connect to a dcerpc interface of a domains PDC */
+NTSTATUS libnet_rpc_connect_pdc(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_rpc_connect *r)
+{
+       NTSTATUS status;
+       const char *binding = NULL;
+       const char *pdc = NULL;
+
+       /* TODO: find real PDC!
+        *       for now I use the  lp_netbios_name()
+        *       that's the most important for me as we don't have
+        *       smbpasswd in samba4 (and this is good!:-) --metze
+        */
+       pdc = lp_netbios_name();
+
+       binding = talloc_asprintf(mem_ctx, "ncacn_np:%s",pdc);
+
+       status = dcerpc_pipe_connect(&r->pdc.out.dcerpc_pipe,
+                                       binding,
+                                       r->pdc.in.dcerpc_iface_uuid,
+                                       r->pdc.in.dcerpc_iface_version,
+                                       ctx->user.domain_name,
+                                       ctx->user.account_name,
+                                       ctx->user.password); 
+
+       return status;
+}
+
 /* connect to a dcerpc interface */
 NTSTATUS libnet_rpc_connect(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_rpc_connect *r)
 {
-       return NT_STATUS_NOT_IMPLEMENTED;
+       switch (r->pdc.level) {
+               case LIBNET_RPC_CONNECT_PDC:
+                       return libnet_rpc_connect_pdc(ctx, mem_ctx, r);
+       }
+
+       return NT_STATUS_INVALID_LEVEL;
 }
index c9c549fcff22d4e79fedd84d3c241d8321d69c4e..9daa3f401f75a5ae7087da5fbe34a682f731046b 100644 (file)
@@ -46,6 +46,9 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
        if (!libnetctx) {
                return -1;      
        }
+       libnetctx->user.account_name    = ctx->user.account_name;
+       libnetctx->user.domain_name     = ctx->user.domain_name;
+       libnetctx->user.password        = ctx->user.password;
 
        /* prepare password change */
        r.generic.level                 = LIBNET_CHANGE_PASSWORD_GENERIC;