mlsvc_dssetup.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * Active Directory Setup RPC interface used by Windows2000.
2N/A */
2N/A
2N/A#include <strings.h>
2N/A#include <stdlib.h>
2N/A#include <netdb.h>
2N/A
2N/A#include <smbsrv/libsmb.h>
2N/A#include <smbsrv/libmlrpc.h>
2N/A#include <smbsrv/libmlsvc.h>
2N/A#include <smbsrv/mlsvc_util.h>
2N/A#include <smbsrv/ndl/dssetup.ndl>
2N/A#include <smbsrv/ntstatus.h>
2N/A#include <smbsrv/smbinfo.h>
2N/A#include <smbsrv/nmpipes.h>
2N/A
2N/Astatic int dssetup_DsRoleGetPrimaryDomainInfo(void *, struct mlrpc_xaction *);
2N/A
2N/Astatic mlrpc_stub_table_t dssetup_stub_table[] = {
2N/A { dssetup_DsRoleGetPrimaryDomainInfo,
2N/A DSSETUP_OPNUM_DsRoleGetPrimaryDomainInfo },
2N/A {0}
2N/A};
2N/A
2N/Astatic mlrpc_service_t dssetup_service = {
2N/A "DSSETUP", /* name */
2N/A "Active Directory Setup", /* desc */
2N/A "\\lsarpc", /* endpoint */
2N/A PIPE_LSASS, /* sec_addr_port */
2N/A "3919286a-b10c-11d0-9ba800c04fd92ef5", 0, /* abstract */
2N/A "8a885d04-1ceb-11c9-9fe808002b104860", 2, /* transfer */
2N/A 0, /* no bind_instance_size */
2N/A 0, /* no bind_req() */
2N/A 0, /* no unbind_and_close() */
2N/A 0, /* use generic_call_stub() */
2N/A &TYPEINFO(dssetup_interface), /* interface ti */
2N/A dssetup_stub_table /* stub_table */
2N/A};
2N/A
2N/A/*
2N/A * dssetup_initialize
2N/A *
2N/A * This function registers the DSSETUP interface with the RPC runtime
2N/A * library. It must be called in order to use either the client side
2N/A * or the server side functions.
2N/A */
2N/Avoid
2N/Adssetup_initialize(void)
2N/A{
2N/A (void) mlrpc_register_service(&dssetup_service);
2N/A}
2N/A
2N/A/*
2N/A * Request for primary domain information and status.
2N/A */
2N/Astatic int
2N/Adssetup_DsRoleGetPrimaryDomainInfo(void *arg, struct mlrpc_xaction *mxa)
2N/A{
2N/A struct dssetup_DsRoleGetPrimaryDomainInfo *param = arg;
2N/A char dns_domain[MAXHOSTNAMELEN];
2N/A smb_ntdomain_t *di;
2N/A DWORD status;
2N/A
2N/A switch (param->level) {
2N/A case DS_ROLE_BASIC_INFORMATION:
2N/A break;
2N/A
2N/A case DS_ROLE_UPGRADE_STATUS:
2N/A case DS_ROLE_OP_STATUS:
2N/A default:
2N/A bzero(param,
2N/A sizeof (struct dssetup_DsRoleGetPrimaryDomainInfo));
2N/A param->status = NT_SC_ERROR(NT_STATUS_INVALID_LEVEL);
2N/A return (MLRPC_DRC_OK);
2N/A }
2N/A
2N/A di = smb_getdomaininfo(0);
2N/A (void) smb_getdomainname(dns_domain, MAXHOSTNAMELEN);
2N/A
2N/A if (di == NULL) {
2N/A bzero(param,
2N/A sizeof (struct dssetup_DsRoleGetPrimaryDomainInfo));
2N/A param->status = NT_SC_ERROR(NT_STATUS_CANT_ACCESS_DOMAIN_INFO);
2N/A return (MLRPC_DRC_OK);
2N/A }
2N/A
2N/A (void) utf8_strlwr(dns_domain);
2N/A
2N/A param->ru.info1.role = DS_ROLE_MEMBER_SERVER;
2N/A param->ru.info1.flags = 0;
2N/A param->ru.info1.nt_domain =
2N/A (uint8_t *)MLRPC_HEAP_STRSAVE(mxa, di->domain);
2N/A param->ru.info1.dns_domain =
2N/A (uint8_t *)MLRPC_HEAP_STRSAVE(mxa, dns_domain);
2N/A param->ru.info1.forest =
2N/A (uint8_t *)MLRPC_HEAP_STRSAVE(mxa, dns_domain);
2N/A bzero(&param->ru.info1.domain_guid, sizeof (mlrpc_uuid_t));
2N/A
2N/A if (param->ru.info1.nt_domain == NULL ||
2N/A param->ru.info1.dns_domain == NULL ||
param->ru.info1.forest == NULL) {
bzero(param,
sizeof (struct dssetup_DsRoleGetPrimaryDomainInfo));
status = NT_SC_ERROR(NT_STATUS_NO_MEMORY);
} else {
status = NT_STATUS_SUCCESS;
}
param->status = status;
return (MLRPC_DRC_OK);
}
DECL_FIXUP_STRUCT(dssetup_GetPrimaryDomainInfo_ru);
DECL_FIXUP_STRUCT(dssetup_GetPrimaryDomainInfoRes);
DECL_FIXUP_STRUCT(dssetup_DsRoleGetPrimaryDomainInfo);
void
fixup_dssetup_DsRoleGetPrimaryDomainInfo(
struct dssetup_DsRoleGetPrimaryDomainInfo *val)
{
unsigned short size1 = 0;
unsigned short size2 = 0;
unsigned short size3 = 0;
switch (val->switch_value) {
CASE_INFO_ENT(dssetup_DsRolePrimaryDomInfo, 1);
CASE_INFO_ENT(dssetup_DsRolePrimaryDomInfo, 2);
CASE_INFO_ENT(dssetup_DsRolePrimaryDomInfo, 3);
default:
return;
};
size2 = size1 + (2 * sizeof (DWORD));
size3 = size2 + sizeof (mlrpcconn_request_hdr_t) + sizeof (DWORD);
FIXUP_PDU_SIZE(dssetup_GetPrimaryDomainInfo_ru, size1);
FIXUP_PDU_SIZE(dssetup_GetPrimaryDomainInfoRes, size2);
FIXUP_PDU_SIZE(dssetup_DsRoleGetPrimaryDomainInfo, size3);
}