00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "includes.h"
00028
00029 #undef DBGC_CLASS
00030 #define DBGC_CLASS DBGC_RPC_SRV
00031
00032
00033
00034
00035
00036 static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info)
00037 {
00038 DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic;
00039 const char *netbios_domain = "";
00040 fstring dnsdomain;
00041
00042 DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
00043
00044 if ( !(basic = TALLOC_ZERO_P(ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC)) ) {
00045 DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error! talloc_xero() failed\n"));
00046 return NT_STATUS_NO_MEMORY;
00047 }
00048
00049 switch ( lp_server_role() ) {
00050 case ROLE_STANDALONE:
00051 basic->machine_role = DSROLE_STANDALONE_SRV;
00052 basic->netbios_ptr = 1;
00053 netbios_domain = get_global_sam_name();
00054 break;
00055 case ROLE_DOMAIN_MEMBER:
00056 basic->netbios_ptr = 1;
00057 netbios_domain = lp_workgroup();
00058 basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV;
00059 break;
00060 case ROLE_DOMAIN_BDC:
00061 basic->netbios_ptr = 1;
00062 netbios_domain = get_global_sam_name();
00063 basic->machine_role = DSROLE_BDC;
00064 break;
00065 case ROLE_DOMAIN_PDC:
00066 basic->netbios_ptr = 1;
00067 netbios_domain = get_global_sam_name();
00068 basic->machine_role = DSROLE_PDC;
00069 break;
00070 }
00071
00072
00073
00074 init_unistr2( &basic->netbios_domain, netbios_domain, UNI_STR_TERMINATE);
00075
00076 if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
00077 basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;
00078
00079
00080
00081 if ( lp_security() == SEC_ADS ) {
00082 fstrcpy( dnsdomain, lp_realm() );
00083 strlower_m( dnsdomain );
00084
00085 basic->dnsname_ptr = 1;
00086 init_unistr2( &basic->dns_domain, dnsdomain, UNI_STR_TERMINATE);
00087
00088
00089
00090 basic->forestname_ptr = 1;
00091 init_unistr2( &basic->forest_domain, dnsdomain, UNI_STR_TERMINATE);
00092 } else {
00093
00094
00095 basic->dnsname_ptr = 0;
00096 basic->forestname_ptr = 0;
00097 }
00098
00099 *info = basic;
00100
00101 return NT_STATUS_OK;
00102 }
00103
00104
00105
00106
00107
00108 NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, DS_R_GETPRIMDOMINFO *r_u)
00109 {
00110 NTSTATUS result = NT_STATUS_OK;
00111 uint32 level = q_u->level;
00112
00113 switch ( level ) {
00114
00115 case DsRolePrimaryDomainInfoBasic:
00116 r_u->level = DsRolePrimaryDomainInfoBasic;
00117 r_u->ptr = 1;
00118 result = fill_dsrole_dominfo_basic( p->mem_ctx, &r_u->info.basic );
00119 break;
00120
00121 default:
00122 DEBUG(0,("_dsrole_get_primary_dominfo: Unsupported info level [%d]!\n",
00123 level));
00124 result = NT_STATUS_INVALID_LEVEL;
00125 }
00126
00127 return result;
00128 }
00129
00130
00131