1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 /* 26 * Client side for the DSSETUP RPC service. 27 */ 28 29 #include <string.h> 30 #include <strings.h> 31 #include <smbsrv/wintypes.h> 32 #include <smbsrv/libsmb.h> 33 #include <smbsrv/ndl/dssetup.ndl> 34 #include <smbsrv/libmlsvc.h> 35 36 int 37 dssetup_get_domain_info(ds_primary_domain_info_t *ds_info) 38 { 39 dssetup_DsRoleGetPrimaryDomainInfo_t arg; 40 struct dssetup_DsRolePrimaryDomInfo1 *info; 41 smb_domainex_t di; 42 mlsvc_handle_t handle; 43 int opnum; 44 int rc; 45 46 if (!smb_domain_getinfo(&di)) 47 return (-1); 48 49 if (ndr_rpc_bind(&handle, di.d_dc, di.d_primary.di_nbname, 50 MLSVC_ANON_USER, "DSSETUP") != 0) 51 return (-1); 52 53 opnum = DSSETUP_OPNUM_DsRoleGetPrimaryDomainInfo; 54 bzero(&arg, sizeof (dssetup_DsRoleGetPrimaryDomainInfo_t)); 55 arg.level = DS_ROLE_BASIC_INFORMATION; 56 57 rc = ndr_rpc_call(&handle, opnum, &arg); 58 if ((rc != 0) || (arg.status != 0) || arg.info == NULL) { 59 ndr_rpc_unbind(&handle); 60 return (-1); 61 } 62 63 info = &arg.info->ru.info1; 64 65 if (info->nt_domain == NULL || 66 info->dns_domain == NULL || 67 info->forest == NULL) { 68 ndr_rpc_unbind(&handle); 69 return (-1); 70 } 71 72 bcopy(info, ds_info, sizeof (ds_primary_domain_info_t)); 73 ds_info->nt_domain = (uint8_t *)strdup((char *)info->nt_domain); 74 ds_info->dns_domain = (uint8_t *)strdup((char *)info->dns_domain); 75 ds_info->forest = (uint8_t *)strdup((char *)info->forest); 76 77 ndr_rpc_unbind(&handle); 78 return (0); 79 } 80 81 int 82 dssetup_check_service(void) 83 { 84 ds_primary_domain_info_t ds_info; 85 int rc; 86 87 bzero(&ds_info, sizeof (ds_primary_domain_info_t)); 88 89 if ((rc = dssetup_get_domain_info(&ds_info)) == 0) { 90 free(ds_info.nt_domain); 91 free(ds_info.dns_domain); 92 free(ds_info.forest); 93 } 94 95 return (rc); 96 } 97