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 (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <strings.h>
2N/A#include <smbsrv/libsmb.h>
2N/A#include <smbsrv/ndl/srvsvc.ndl>
2N/A#include <smbsrv/libntsvcs.h>
2N/A
2N/Aint
2N/Awkssvc_getinfo(char *server, char *domain, wksta_info_t *info)
2N/A{
2N/A struct mslm_NetWkstaGetInfo arg;
2N/A struct mslm_WKSTA_INFO_100 *info100;
2N/A mlsvc_handle_t handle;
2N/A char user[SMB_USERNAME_MAXLEN];
2N/A int opnum;
2N/A int rc;
2N/A
2N/A if (server == NULL || domain == NULL || info == NULL)
2N/A return (-1);
2N/A
2N/A smb_ipc_get_user(user, SMB_USERNAME_MAXLEN);
2N/A
2N/A if (ndr_rpc_bind(&handle, server, domain, user, "Workstation") != 0)
2N/A return (-1);
2N/A
2N/A opnum = WKSSVC_OPNUM_NetWkstaGetInfo;
2N/A bzero(&arg, sizeof (struct mslm_NetWkstaGetInfo));
2N/A arg.level = 100;
2N/A
2N/A rc = ndr_rpc_call(&handle, opnum, &arg);
2N/A
2N/A /* LINTED E_BAD_PTR_CAST_ALIGN */
2N/A info100 = (struct mslm_WKSTA_INFO_100 *)arg.result.bufptr.nullptr;
2N/A
2N/A if (rc != 0 || arg.status != 0 || info100 == NULL) {
2N/A ndr_rpc_unbind(&handle);
2N/A return (-1);
2N/A }
2N/A
2N/A info->wki_platform_id = info100->wki100_platform_id;
2N/A info->wki_computername = strdup((char *)info100->wki100_computername);
2N/A info->wki_domainname = strdup((char *)info100->wki100_langroup);
2N/A info->wki_ver_major = info100->wki100_ver_major;
2N/A info->wki_ver_minor = info100->wki100_ver_minor;
2N/A
2N/A ndr_rpc_unbind(&handle);
2N/A
2N/A if (info->wki_computername == NULL || info->wki_domainname == NULL) {
2N/A wkssvc_freeinfo(info);
2N/A return (-1);
2N/A }
2N/A
2N/A return (0);
2N/A}
2N/A
2N/Avoid
2N/Awkssvc_freeinfo(wksta_info_t *info)
2N/A{
2N/A free(info->wki_computername);
2N/A free(info->wki_domainname);
2N/A bzero(info, sizeof (wksta_info_t));
2N/A}