first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[kai/samba.git] / source / rpc_client / msrpc_lsarpc.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    NT Domain Authentication SMB / MSRPC client
5    Copyright (C) Andrew Tridgell 1994-1999
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1999
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24 #ifdef SYSLOG
25 #undef SYSLOG
26 #endif
27
28 #include "includes.h"
29 #include "nterr.h"
30
31 extern int DEBUGLEVEL;
32
33 #define DEBUG_TESTING
34
35 /****************************************************************************
36 nt lsa query secret
37 ****************************************************************************/
38 BOOL msrpc_lsa_query_secret(const char* srv_name,
39                                 const char* secret_name,
40                                 STRING2 *secret,
41                                 NTTIME *last_update)
42 {
43         BOOL res = True;
44         BOOL res1;
45         BOOL res2;
46
47         POLICY_HND pol_sec;
48         POLICY_HND lsa_pol;
49
50         /* lookup domain controller; receive a policy handle */
51         res = res ? lsa_open_policy2( srv_name,
52                                 &lsa_pol, False) : False;
53
54         /* lookup domain controller; receive a policy handle */
55         res1 = res ? lsa_open_secret( &lsa_pol,
56                                 secret_name, 0x02000000, &pol_sec) : False;
57
58         res2 = res1 ? lsa_query_secret(&pol_sec, secret, last_update) : False;
59
60         res1 = res1 ? lsa_close(&pol_sec) : False;
61
62         res = res ? lsa_close(&lsa_pol) : False;
63
64         return res2;
65 }