~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/rpc_server/srv_lsa_ds_nt.c

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
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.
9
 
 *
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.
14
 
 *  
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.
19
 
 *  
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.
23
 
 */
24
 
 
25
 
/* Implementation of registry functions. */
26
 
 
27
 
#include "includes.h"
28
 
 
29
 
#undef DBGC_CLASS
30
 
#define DBGC_CLASS DBGC_RPC_SRV
31
 
 
32
 
/********************************************************************
33
 
 Fill in a DS_DOMINFO_CTR structure
34
 
 ********************************************************************/
35
 
 
36
 
static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) 
37
 
{
38
 
        DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic;
39
 
        const char *netbios_domain;
40
 
        fstring dnsdomain;
41
 
 
42
 
        DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
43
 
 
44
 
        if ( !(basic = TALLOC_ZERO_P(ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC)) ) {
45
 
                DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error!  talloc_xero() failed\n"));
46
 
                return NT_STATUS_NO_MEMORY;
47
 
        }
48
 
 
49
 
        get_mydnsdomname(dnsdomain);
50
 
        strlower_m(dnsdomain);
51
 
 
52
 
        switch ( lp_server_role() ) {
53
 
                case ROLE_STANDALONE:
54
 
                        basic->machine_role = DSROLE_STANDALONE_SRV;
55
 
                        break;
56
 
                case ROLE_DOMAIN_MEMBER:
57
 
                        basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV;
58
 
                        break;
59
 
                case ROLE_DOMAIN_BDC:
60
 
                        basic->machine_role = DSROLE_BDC;
61
 
                        basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE;
62
 
                        if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
63
 
                                basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;
64
 
                        break;
65
 
                case ROLE_DOMAIN_PDC:
66
 
                        basic->machine_role = DSROLE_PDC;
67
 
                        basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE;
68
 
                        if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
69
 
                                basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;
70
 
                        break;
71
 
        }
72
 
 
73
 
        basic->unknown = 0x6173;                /* seen on the wire; maybe padding */
74
 
 
75
 
        /* always set netbios name */
76
 
 
77
 
        basic->netbios_ptr = 1;
78
 
        netbios_domain = get_global_sam_name();
79
 
        init_unistr2( &basic->netbios_domain, netbios_domain, UNI_FLAGS_NONE);
80
 
 
81
 
        basic->dnsname_ptr = 1;
82
 
        init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE);
83
 
        basic->forestname_ptr = 1;
84
 
        init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE);
85
 
        
86
 
 
87
 
        /* fill in some additional fields if we are a member of an AD domain */
88
 
 
89
 
        if ( lp_security() == SEC_ADS ) {       
90
 
                /* TODO */
91
 
                ;;
92
 
        }
93
 
 
94
 
        *info = basic;
95
 
 
96
 
        return NT_STATUS_OK;
97
 
}
98
 
 
99
 
/********************************************************************
100
 
 Implement the DsroleGetPrimaryDomainInfo() call
101
 
 ********************************************************************/
102
 
 
103
 
NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, DS_R_GETPRIMDOMINFO *r_u)
104
 
{
105
 
        NTSTATUS result = NT_STATUS_OK;
106
 
        uint32 level = q_u->level;
107
 
 
108
 
        switch ( level ) {
109
 
 
110
 
                case DsRolePrimaryDomainInfoBasic:
111
 
                        r_u->level = DsRolePrimaryDomainInfoBasic;
112
 
                        r_u->ptr = 1;
113
 
                        result = fill_dsrole_dominfo_basic( p->mem_ctx, &r_u->info.basic );
114
 
                        break;
115
 
 
116
 
                default:
117
 
                        DEBUG(0,("_dsrole_get_primary_dominfo: Unsupported info level [%d]!\n",
118
 
                                level));
119
 
                        result = NT_STATUS_INVALID_LEVEL;
120
 
        }
121
 
 
122
 
        return result;
123
 
}
124
 
 
125
 
 
126