2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-2000
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 2000
7 Copyright (C) Shirish Kalele 2000
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "rpc_parse.h"
26 #include "rpc_client.h"
29 extern int DEBUGLEVEL
;
31 /* Called by all dfs operations to verify if a dfs_root exists at server */
32 static BOOL
_dfs_exist(struct cli_connection
*con
)
38 prs_init(&buf
, 0, 4, False
);
39 prs_init(&rbuf
, 0 ,4, True
);
41 /* make a null request */
42 if(!rpc_con_pipe_req(con
, DFS_EXIST
, &buf
, &rbuf
))
44 DEBUG(5,("Null request unsuccessful!\n"));
46 cli_connection_unlink(con
);
49 if(!dfs_io_r_dfs_exist("", &q_d
, &rbuf
, 0))
53 return q_d
.dfs_exist_flag
;
56 BOOL
dfs_remove(char *srv_name
, char *dfs_entrypath
, char *dfs_servername
,
61 BOOL valid_cfg
= False
;
63 struct cli_connection
*con
=NULL
;
65 prs_init(&buf
, 0, 4, False
);
66 prs_init(&rbuf
, 0 ,4, True
);
67 if (!cli_connection_init(srv_name
, PIPE_NETDFS
, &con
))
70 /* check if server is a dfs server */
73 DEBUG(5,("dfs_remove: No Dfs root at \\\\%s\n",srv_name
));
77 /* store the parameters */
78 make_dfs_q_dfs_remove(&q_d
, dfs_entrypath
, dfs_servername
, dfs_sharename
);
80 /* turn parameters into data stream */
81 if(dfs_io_q_dfs_remove("", &q_d
, &buf
, 0) &&
82 rpc_con_pipe_req(con
, DFS_REMOVE
, &buf
, &rbuf
))
88 dfs_io_r_dfs_remove("", &r_d
, &rbuf
, 0);
89 p
= (rbuf
.offset
!= 0);
91 if(p
&& r_d
.status
!=0)
93 DEBUG(1,("DFS_REMOVE: %s\n",get_nt_error_msg(r_d
.status
)));
100 prs_free_data(&rbuf
);
102 cli_connection_unlink(con
);
106 BOOL
dfs_add(char *srv_name
, char* entrypath
, char* servername
, char* sharename
, char* comment
)
110 BOOL valid_cfg
= False
;
112 struct cli_connection
*con
=NULL
;
114 prs_init(&buf
, 0, 4, False
);
115 prs_init(&rbuf
, 0 ,4, True
);
116 if (!cli_connection_init(srv_name
, PIPE_NETDFS
, &con
))
121 DEBUG(5,("dfs_add: No Dfs root at \\\\%s\n",srv_name
));
125 /* store the parameters */
126 make_dfs_q_dfs_add(&q_d
, entrypath
, servername
, sharename
, comment
,
129 /* turn parameters into data stream */
130 if(dfs_io_q_dfs_add("", &q_d
, &buf
, 0) &&
131 rpc_con_pipe_req(con
, DFS_ADD
, &buf
, &rbuf
))
137 dfs_io_r_dfs_add("", &r_d
, &rbuf
, 0);
138 p
= (rbuf
.offset
!= 0);
140 if(p
&& r_d
.status
!=0)
142 DEBUG(1,("DFS_ADD: %s\n",get_nt_error_msg(r_d
.status
)));
149 prs_free_data(&rbuf
);
151 cli_connection_unlink(con
);
155 uint32
dfs_enum(char *srv_name
, uint32 level
, DFS_INFO_CTR
*ctr
)
159 BOOL valid_cfg
= False
;
161 uint32 res
= NT_STATUS_UNSUCCESSFUL
;
163 struct cli_connection
*con
=NULL
;
165 prs_init(&buf
, 0, 4, False
);
166 prs_init(&rbuf
, 0 ,4, True
);
167 if (!cli_connection_init(srv_name
, PIPE_NETDFS
, &con
))
168 return NT_STATUS_PIPE_NOT_AVAILABLE
;
172 DEBUG(5,("dfs_add: No Dfs root at \\\\%s\n",srv_name
));
173 return NT_STATUS_OBJECT_PATH_NOT_FOUND
;
176 /* store the parameters */
177 make_dfs_q_dfs_enum(&q_d
, level
, ctr
);
179 /* turn parameters into data stream */
180 if(dfs_io_q_dfs_enum("", &q_d
, &buf
, 0) &&
181 rpc_con_pipe_req(con
, DFS_ENUM
, &buf
, &rbuf
))
188 dfs_io_r_dfs_enum("", &r_d
, &rbuf
, 0);
189 p
= (rbuf
.offset
!= 0);
191 if(p
&& r_d
.status
!=0)
193 DEBUG(1,("DFS_ENUM: %s\n",get_nt_error_msg(r_d
.status
)));
201 prs_free_data(&rbuf
);
203 cli_connection_unlink(con
);