0001-01-01 02:30:17 +02:30
/*
Unix SMB / CIFS implementation .
RPC pipe client
Copyright ( C ) Gerald Carter 2002 ,
2005-09-30 21:13:37 +04:00
Copyright ( C ) Jeremy Allison 2005.
0001-01-01 02:30:17 +02:30
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
0001-01-01 02:30:17 +02:30
( 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 , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
/* implementations of client side DsXXX() functions */
0001-01-01 02:30:17 +02:30
/********************************************************************
Get information about the server and directory services
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-06-09 02:10:34 +04:00
NTSTATUS rpccli_ds_getprimarydominfo ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx ,
uint16 level , DS_DOMINFO_CTR * ctr )
0001-01-01 02:30:17 +02:30
{
prs_struct qbuf , rbuf ;
DS_Q_GETPRIMDOMINFO q ;
DS_R_GETPRIMDOMINFO r ;
NTSTATUS result ;
ZERO_STRUCT ( q ) ;
ZERO_STRUCT ( r ) ;
q . level = level ;
2005-09-30 21:13:37 +04:00
CLI_DO_RPC ( cli , mem_ctx , PI_LSARPC_DS , DS_GETPRIMDOMINFO ,
q , r ,
qbuf , rbuf ,
ds_io_q_getprimdominfo ,
ds_io_r_getprimdominfo ,
NT_STATUS_UNSUCCESSFUL ) ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
/* Return basic info - if we are requesting at info != 1 then
there could be trouble . */
0001-01-01 02:30:17 +02:30
result = r . status ;
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
if ( r . ptr & & ctr ) {
2004-12-07 21:25:53 +03:00
ctr - > basic = TALLOC_P ( mem_ctx , DSROLE_PRIMARY_DOMAIN_INFO_BASIC ) ;
0001-01-01 02:30:17 +02:30
if ( ! ctr - > basic )
goto done ;
0001-01-01 02:30:17 +02:30
memcpy ( ctr - > basic , r . info . basic , sizeof ( DSROLE_PRIMARY_DOMAIN_INFO_BASIC ) ) ;
0001-01-01 02:30:17 +02:30
}
0001-01-01 02:30:17 +02:30
done :
0001-01-01 02:30:17 +02:30
0001-01-01 02:30:17 +02:30
return result ;
}
0001-01-01 02:30:17 +02:30
/********************************************************************
Enumerate trusted domains in an AD forest
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-06-09 02:10:34 +04:00
NTSTATUS rpccli_ds_enum_domain_trusts ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx ,
const char * server , uint32 flags ,
struct ds_domain_trust * * trusts ,
uint32 * num_domains )
0001-01-01 02:30:17 +02:30
{
prs_struct qbuf , rbuf ;
DS_Q_ENUM_DOM_TRUSTS q ;
DS_R_ENUM_DOM_TRUSTS r ;
NTSTATUS result ;
ZERO_STRUCT ( q ) ;
ZERO_STRUCT ( r ) ;
init_q_ds_enum_domain_trusts ( & q , server , flags ) ;
2005-10-11 21:36:29 +04:00
CLI_DO_RPC ( cli , mem_ctx , PI_NETLOGON , DS_ENUM_DOM_TRUSTS ,
2005-09-30 21:13:37 +04:00
q , r ,
qbuf , rbuf ,
ds_io_q_enum_domain_trusts ,
ds_io_r_enum_domain_trusts ,
NT_STATUS_UNSUCCESSFUL ) ;
0001-01-01 02:30:17 +02:30
result = r . status ;
0001-01-01 02:30:17 +02:30
if ( NT_STATUS_IS_OK ( result ) ) {
0001-01-01 02:30:17 +02:30
int i ;
0001-01-01 02:30:17 +02:30
* num_domains = r . num_domains ;
2007-04-30 06:39:34 +04:00
if ( r . num_domains ) {
* trusts = TALLOC_ARRAY ( mem_ctx , struct ds_domain_trust , r . num_domains ) ;
0001-01-01 02:30:17 +02:30
2007-04-30 06:39:34 +04:00
if ( * trusts = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
* trusts = NULL ;
2006-06-17 11:43:56 +04:00
}
0001-01-01 02:30:17 +02:30
for ( i = 0 ; i < * num_domains ; i + + ) {
( * trusts ) [ i ] . flags = r . domains . trusts [ i ] . flags ;
( * trusts ) [ i ] . parent_index = r . domains . trusts [ i ] . parent_index ;
( * trusts ) [ i ] . trust_type = r . domains . trusts [ i ] . trust_type ;
( * trusts ) [ i ] . trust_attributes = r . domains . trusts [ i ] . trust_attributes ;
( * trusts ) [ i ] . guid = r . domains . trusts [ i ] . guid ;
0001-01-01 02:30:17 +02:30
if ( r . domains . trusts [ i ] . sid_ptr ) {
0001-01-01 02:30:17 +02:30
sid_copy ( & ( * trusts ) [ i ] . sid , & r . domains . trusts [ i ] . sid . sid ) ;
} else {
ZERO_STRUCT ( ( * trusts ) [ i ] . sid ) ;
}
0001-01-01 02:30:17 +02:30
if ( r . domains . trusts [ i ] . netbios_ptr ) {
0001-01-01 02:30:17 +02:30
( * trusts ) [ i ] . netbios_domain = unistr2_tdup ( mem_ctx , & r . domains . trusts [ i ] . netbios_domain ) ;
} else {
( * trusts ) [ i ] . netbios_domain = NULL ;
}
0001-01-01 02:30:17 +02:30
if ( r . domains . trusts [ i ] . dns_ptr ) {
0001-01-01 02:30:17 +02:30
( * trusts ) [ i ] . dns_domain = unistr2_tdup ( mem_ctx , & r . domains . trusts [ i ] . dns_domain ) ;
} else {
( * trusts ) [ i ] . dns_domain = NULL ;
}
0001-01-01 02:30:17 +02:30
}
0001-01-01 02:30:17 +02:30
}
0001-01-01 02:30:17 +02:30
return result ;
}