r1919: paasword change basicly works now:-)
[tprouty/samba.git] / source4 / libnet / libnet_rpc.c
1 /* 
2    Unix SMB/CIFS implementation.
3    
4    Copyright (C) Stefan Metzmacher      2004
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 /* connect to a dcerpc interface of a domains PDC */
24 NTSTATUS libnet_rpc_connect_pdc(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_rpc_connect *r)
25 {
26         NTSTATUS status;
27         const char *binding = NULL;
28         const char *pdc = NULL;
29
30         /* TODO: find real PDC!
31          *       for now I use the  lp_netbios_name()
32          *       that's the most important for me as we don't have
33          *       smbpasswd in samba4 (and this is good!:-) --metze
34          */
35         pdc = lp_netbios_name();
36
37         binding = talloc_asprintf(mem_ctx, "ncacn_np:%s",pdc);
38
39         status = dcerpc_pipe_connect(&r->pdc.out.dcerpc_pipe,
40                                         binding,
41                                         r->pdc.in.dcerpc_iface_uuid,
42                                         r->pdc.in.dcerpc_iface_version,
43                                         ctx->user.domain_name,
44                                         ctx->user.account_name,
45                                         ctx->user.password); 
46
47         return status;
48 }
49
50 /* connect to a dcerpc interface */
51 NTSTATUS libnet_rpc_connect(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_rpc_connect *r)
52 {
53         switch (r->pdc.level) {
54                 case LIBNET_RPC_CONNECT_PDC:
55                         return libnet_rpc_connect_pdc(ctx, mem_ctx, r);
56         }
57
58         return NT_STATUS_INVALID_LEVEL;
59 }