2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997.
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997.
6 * Copyright (C) Paul Ashton 1997.
7 * Copyright (C) Jeremy Allison 2001.
8 * Copyright (C) Gerald Carter 2002.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* Implementation of registry functions. */
30 #define DBGC_CLASS DBGC_RPC_SRV
32 /********************************************************************
33 Fill in a DS_DOMINFO_CTR structure
34 ********************************************************************/
36 static NTSTATUS
fill_dsrole_dominfo_basic(TALLOC_CTX
*ctx
, DSROLE_PRIMARY_DOMAIN_INFO_BASIC
**info
)
38 DSROLE_PRIMARY_DOMAIN_INFO_BASIC
*basic
;
39 const char *netbios_domain
;
42 DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
44 if ( !(basic
= talloc_zero(ctx
, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC
))) ) {
45 DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error! talloc_xero() failed\n"));
46 return NT_STATUS_NO_MEMORY
;
49 switch ( lp_server_role() ) {
51 basic
->machine_role
= DSROLE_STANDALONE_SRV
;
53 case ROLE_DOMAIN_MEMBER
:
54 basic
->machine_role
= DSROLE_DOMAIN_MEMBER_SRV
;
57 basic
->machine_role
= DSROLE_BDC
;
58 basic
->flags
= DSROLE_PRIMARY_DS_RUNNING
|DSROLE_PRIMARY_DS_MIXED_MODE
;
59 if ( secrets_fetch_domain_guid( lp_workgroup(), &basic
->domain_guid
) )
60 basic
->flags
|= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT
;
61 get_mydnsdomname(dnsdomain
);
62 strlower_m(dnsdomain
);
65 basic
->machine_role
= DSROLE_PDC
;
66 basic
->flags
= DSROLE_PRIMARY_DS_RUNNING
|DSROLE_PRIMARY_DS_MIXED_MODE
;
67 if ( secrets_fetch_domain_guid( lp_workgroup(), &basic
->domain_guid
) )
68 basic
->flags
|= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT
;
69 get_mydnsdomname(dnsdomain
);
70 strlower_m(dnsdomain
);
74 basic
->unknown
= 0x6173; /* seen on the wire; maybe padding */
76 /* always set netbios name */
78 basic
->netbios_ptr
= 1;
79 netbios_domain
= get_global_sam_name();
80 init_unistr2( &basic
->netbios_domain
, netbios_domain
, UNI_FLAGS_NONE
);
82 basic
->dnsname_ptr
= 1;
83 init_unistr2( &basic
->dns_domain
, dnsdomain
, UNI_FLAGS_NONE
);
84 basic
->forestname_ptr
= 1;
85 init_unistr2( &basic
->forest_domain
, dnsdomain
, UNI_FLAGS_NONE
);
88 /* fill in some additional fields if we are a member of an AD domain */
90 if ( lp_security() == SEC_ADS
) {
100 /********************************************************************
101 Implement the DsroleGetPrimaryDomainInfo() call
102 ********************************************************************/
104 NTSTATUS
_dsrole_get_primary_dominfo(pipes_struct
*p
, DS_Q_GETPRIMDOMINFO
*q_u
, DS_R_GETPRIMDOMINFO
*r_u
)
106 NTSTATUS result
= NT_STATUS_OK
;
107 uint32 level
= q_u
->level
;
111 case DsRolePrimaryDomainInfoBasic
:
112 r_u
->level
= DsRolePrimaryDomainInfoBasic
;
114 result
= fill_dsrole_dominfo_basic( p
->mem_ctx
, &r_u
->info
.basic
);
118 DEBUG(0,("_dsrole_get_primary_dominfo: Unsupported info level [%d]!\n",
120 result
= NT_STATUS_INVALID_LEVEL
;