svn commit: samba r1919 - in branches/SAMBA_4_0/source: libnet utils/net

metze at samba.org metze at samba.org
Thu Aug 19 13:32:06 GMT 2004


Author: metze
Date: 2004-08-19 13:32:06 +0000 (Thu, 19 Aug 2004)
New Revision: 1919

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=1919&nolog=1

Log:
paasword change basicly works now:-)

but we need to find the real pdc for the users domain
and fallback to other levels

metze

Modified:
   branches/SAMBA_4_0/source/libnet/libnet.h
   branches/SAMBA_4_0/source/libnet/libnet_passwd.c
   branches/SAMBA_4_0/source/libnet/libnet_rpc.c
   branches/SAMBA_4_0/source/utils/net/net_password.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet.h	2004-08-19 13:07:49 UTC (rev 1918)
+++ branches/SAMBA_4_0/source/libnet/libnet.h	2004-08-19 13:32:06 UTC (rev 1919)
@@ -25,6 +25,11 @@
 	 * 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 */

Modified: branches/SAMBA_4_0/source/libnet/libnet_passwd.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_passwd.c	2004-08-19 13:07:49 UTC (rev 1918)
+++ branches/SAMBA_4_0/source/libnet/libnet_passwd.c	2004-08-19 13:32:06 UTC (rev 1919)
@@ -109,11 +109,11 @@
 	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);
 

Modified: branches/SAMBA_4_0/source/libnet/libnet_rpc.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2004-08-19 13:07:49 UTC (rev 1918)
+++ branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2004-08-19 13:32:06 UTC (rev 1919)
@@ -20,8 +20,40 @@
 
 #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;
 }

Modified: branches/SAMBA_4_0/source/utils/net/net_password.c
===================================================================
--- branches/SAMBA_4_0/source/utils/net/net_password.c	2004-08-19 13:07:49 UTC (rev 1918)
+++ branches/SAMBA_4_0/source/utils/net/net_password.c	2004-08-19 13:32:06 UTC (rev 1919)
@@ -46,6 +46,9 @@
 	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;



More information about the samba-cvs mailing list