2007-12-21 15:51:00 +01:00
/*
* Unix SMB / CIFS implementation .
* NetApi GetDC Support
* Copyright ( C ) Guenther Deschner 2007
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
2008-04-08 02:42:50 +02:00
# include "librpc/gen_ndr/libnetapi.h"
2007-12-21 15:51:00 +01:00
# include "lib/netapi/netapi.h"
2008-04-10 21:52:03 +02:00
# include "lib/netapi/netapi_private.h"
2008-04-08 02:42:50 +02:00
# include "lib/netapi/libnetapi.h"
2007-12-21 15:51:00 +01:00
# include "libnet/libnet.h"
2008-01-18 02:38:35 +01:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-04-08 02:42:50 +02:00
WERROR NetGetDCName_l ( struct libnetapi_ctx * ctx ,
struct NetGetDCName * r )
2007-12-21 15:51:00 +01:00
{
return WERR_NOT_SUPPORTED ;
}
2008-01-18 02:38:35 +01:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-04-08 02:42:50 +02:00
WERROR NetGetDCName_r ( struct libnetapi_ctx * ctx ,
struct NetGetDCName * r )
2007-12-21 15:51:00 +01:00
{
struct cli_state * cli = NULL ;
struct rpc_pipe_client * pipe_cli = NULL ;
NTSTATUS status ;
WERROR werr ;
2008-04-10 22:04:04 +02:00
werr = libnetapi_open_ipc_connection ( ctx , r - > in . server_name , & cli ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2007-12-21 15:51:00 +01:00
goto done ;
}
2008-07-20 17:59:30 +02:00
werr = libnetapi_open_pipe ( ctx , cli , & ndr_table_netlogon . syntax_id ,
& pipe_cli ) ;
2008-04-10 22:44:00 +02:00
if ( ! W_ERROR_IS_OK ( werr ) ) {
2007-12-21 15:51:00 +01:00
goto done ;
2008-04-08 02:42:50 +02:00
}
2007-12-21 15:51:00 +01:00
2008-01-17 10:39:15 +01:00
status = rpccli_netr_GetDcName ( pipe_cli , ctx ,
2008-04-08 02:42:50 +02:00
r - > in . server_name ,
r - > in . domain_name ,
( const char * * ) r - > out . buffer ,
2008-01-31 14:10:22 +01:00
& werr ) ;
2007-12-21 15:51:00 +01:00
done :
return werr ;
}
2008-01-18 02:38:35 +01:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-04-08 02:42:50 +02:00
WERROR NetGetAnyDCName_l ( struct libnetapi_ctx * ctx ,
struct NetGetAnyDCName * r )
2007-12-21 15:51:00 +01:00
{
return WERR_NOT_SUPPORTED ;
}
2008-01-18 02:38:35 +01:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-04-08 02:42:50 +02:00
WERROR NetGetAnyDCName_r ( struct libnetapi_ctx * ctx ,
struct NetGetAnyDCName * r )
2007-12-21 15:51:00 +01:00
{
struct cli_state * cli = NULL ;
struct rpc_pipe_client * pipe_cli = NULL ;
NTSTATUS status ;
WERROR werr ;
2008-04-10 22:04:04 +02:00
werr = libnetapi_open_ipc_connection ( ctx , r - > in . server_name , & cli ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2007-12-21 15:51:00 +01:00
goto done ;
}
2008-07-20 17:59:30 +02:00
werr = libnetapi_open_pipe ( ctx , cli , & ndr_table_netlogon . syntax_id ,
& pipe_cli ) ;
2008-04-10 22:44:00 +02:00
if ( ! W_ERROR_IS_OK ( werr ) ) {
2007-12-21 15:51:00 +01:00
goto done ;
2008-04-10 22:44:00 +02:00
}
2007-12-21 15:51:00 +01:00
status = rpccli_netr_GetAnyDCName ( pipe_cli , ctx ,
2008-04-08 02:42:50 +02:00
r - > in . server_name ,
r - > in . domain_name ,
( const char * * ) r - > out . buffer ,
2007-12-21 15:51:00 +01:00
& werr ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
done :
return werr ;
}
2008-04-08 18:43:51 +02:00
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
WERROR DsGetDcName_l ( struct libnetapi_ctx * ctx ,
struct DsGetDcName * r )
{
NTSTATUS status ;
status = dsgetdcname ( ctx ,
2008-05-08 18:32:22 +02:00
NULL ,
2008-04-08 18:43:51 +02:00
r - > in . domain_name ,
r - > in . domain_guid ,
r - > in . site_name ,
r - > in . flags ,
( struct netr_DsRGetDCNameInfo * * ) r - > out . dc_info ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
libnetapi_set_error_string ( ctx ,
" failed to find DC: %s " ,
get_friendly_nt_error_msg ( status ) ) ;
}
return ntstatus_to_werror ( status ) ;
}
/********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
WERROR DsGetDcName_r ( struct libnetapi_ctx * ctx ,
struct DsGetDcName * r )
{
WERROR werr ;
NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND ;
struct cli_state * cli = NULL ;
struct rpc_pipe_client * pipe_cli = NULL ;
2008-04-10 22:04:04 +02:00
werr = libnetapi_open_ipc_connection ( ctx , r - > in . server_name , & cli ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2008-04-08 18:43:51 +02:00
goto done ;
}
2008-07-20 17:59:30 +02:00
werr = libnetapi_open_pipe ( ctx , cli , & ndr_table_netlogon . syntax_id ,
& pipe_cli ) ;
2008-04-10 22:44:00 +02:00
if ( ! W_ERROR_IS_OK ( werr ) ) {
2008-04-08 18:43:51 +02:00
goto done ;
}
status = rpccli_netr_DsRGetDCName ( pipe_cli ,
ctx ,
r - > in . server_name ,
r - > in . domain_name ,
r - > in . domain_guid ,
NULL ,
r - > in . flags ,
( struct netr_DsRGetDCNameInfo * * ) r - > out . dc_info ,
& werr ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
werr = ntstatus_to_werror ( status ) ;
goto done ;
}
done :
return werr ;
}