samr_lookup.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Security Access Manager RPC (SAMR) library interface functions for
* query and lookup calls.
*/
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <smbsrv/ntstatus.h>
union samr_user_info *);
static void samr_set_user_unknowns(struct samr_SetUserInfo23 *);
static void samr_set_user_logon_hours(struct samr_SetUserInfo *);
/*
* samr_lookup_domain
*
* Lookup up the domain SID for the specified domain name. The handle
* should be one returned from samr_connect. The results will be
* returned in user_info - which should have been allocated by the
* caller. On success sid_name_use will be set to SidTypeDomain.
*
* Returns 0 on success, otherwise returns -ve error code.
*/
int
{
struct samr_LookupDomain arg;
struct mlsvc_rpc_context *context;
int opnum;
int rc;
if (mlsvc_is_null_handle(samr_handle) ||
return (-1);
}
sizeof (samr_handle_t));
length += sizeof (mts_wchar_t);
(void) mlsvc_rpc_init(&heap);
if (rc == 0) {
}
return (rc);
}
/*
* samr_enum_local_domains
*
* Get the list of local domains supported by a server.
*
* Returns NT status codes.
*/
{
struct samr_EnumLocalDomain arg;
struct mlsvc_rpc_context *context;
int opnum;
return (NT_STATUS_INVALID_PARAMETER);
sizeof (samr_handle_t));
arg.enum_context = 0;
(void) mlsvc_rpc_init(&heap);
} else {
/*
* Handle none-mapped status quietly.
*/
if (status != NT_STATUS_NONE_MAPPED)
}
return (status);
}
/*
* samr_lookup_domain_names
*
* Lookup up a name
* returned in user_info - which should have been allocated by the
* caller. On success sid_name_use will be set to SidTypeDomain.
*
* Returns 0 on success. Otherwise returns an NT status code.
*/
{
struct samr_LookupNames arg;
struct mlsvc_rpc_context *context;
int opnum;
if (mlsvc_is_null_handle(domain_handle) ||
return (NT_STATUS_INVALID_PARAMETER);
}
sizeof (samr_handle_t));
length += sizeof (mts_wchar_t);
(void) mlsvc_rpc_init(&heap);
/*
* Handle none-mapped status quietly.
*/
if (status != NT_STATUS_NONE_MAPPED)
} else {
status = 0;
}
return (status);
}
/*
* samr_query_user_info
*
* Query information on a specific user. The handle must be a valid
* user handle obtained via samr_open_user.
*
* Returns 0 on success, otherwise returns -ve error code.
*/
int
union samr_user_info *user_info)
{
struct samr_QueryUserInfo arg;
struct mlsvc_rpc_context *context;
int opnum;
int rc;
return (-1);
sizeof (samr_handle_t));
(void) mlsvc_rpc_init(&heap);
if (rc == 0) {
rc = -1;
else
}
return (rc);
}
/*
* samr_setup_user_info
*
* Private function to set up the samr_user_info data. Dependent on
* the switch value this function may use strdup which will malloc
* memory. The caller is responsible for deallocating this memory.
*
* Returns 0 on success, otherwise returns -1.
*/
{
struct samr_QueryUserInfo1 *info1;
struct samr_QueryUserInfo6 *info6;
switch (switch_value) {
case 1:
return (0);
case 6:
return (0);
case 7:
return (0);
case 8:
return (0);
case 9:
return (0);
case 16:
return (0);
default:
break;
};
return (-1);
}
/*
* samr_query_user_groups
*
* Query the groups for a specific user. The handle must be a valid
* user handle obtained via samr_open_user. The list of groups is
* returned in group_info. Note that group_info->groups is allocated
* using malloc. The caller is responsible for deallocating this
* memory when it is no longer required. If group_info->n_entry is 0
* then no memory was allocated.
*
* Returns 0 on success, otherwise returns -1.
*/
int
{
struct samr_QueryUserGroups arg;
struct mlsvc_rpc_context *context;
int opnum;
int rc;
int nbytes;
return (-1);
sizeof (samr_handle_t));
(void) mlsvc_rpc_init(&heap);
if (rc == 0) {
rc = -1;
} else {
sizeof (struct samr_UserGroups);
rc = -1;
} else {
}
}
}
return (rc);
}
/*
* samr_get_user_pwinfo
*
* Get some user password info. I'm not sure what this is yet but it is
* part of the create user sequence. The handle must be a valid user
* handle. Since I don't know what this is returning, I haven't provided
* any return data yet.
*
* Returns 0 on success. Otherwise returns an NT status code.
*/
{
struct samr_GetUserPwInfo arg;
struct mlsvc_rpc_context *context;
int opnum;
return (NT_STATUS_INVALID_PARAMETER);
sizeof (samr_handle_t));
(void) mlsvc_rpc_init(&heap);
} else {
status = 0;
}
return (status);
}
/*
* samr_set_user_info
*
* Returns 0 on success. Otherwise returns an NT status code.
* NT status codes observed so far:
* NT_STATUS_WRONG_PASSWORD
*/
/*ARGSUSED*/
{
struct samr_SetUserInfo arg;
struct mlsvc_rpc_context *context;
int opnum;
return (NT_STATUS_INVALID_PARAMETER);
(void) mlsvc_rpc_init(&heap);
sizeof (samr_handle_t));
}
return (status);
}
static void
{
/*
* The trust account value used here should probably
* match the one used to create the trust account.
*/
}
/*
* samr_set_user_logon_hours
*
* SamrSetUserInfo appears to contain some logon hours information, which
* looks like a varying, conformant array. The top level contains a value
* (units), which probably indicates the how to interpret the array. The
* array definition looks like it contains a maximum size, an initial
* offset and a bit length (units/8), followed by the bitmap.
*
* (info)
* +-------+
* | units |
* +-------+ (hours)
* | hours |-->+-----------+
* +-------+ | max_is |
* +-----------+
* | first_is |
* +-----------+
* | length_is |
* +------------------------+
* | bitmap[length_is] |
* +---------+--------------+
*
* In the netmon examples seen so far, all bits are set to 1, i.e.
* an array containing 0xff. This is probably the default setting.
*
* ndrgen has a problem with complex [size_is] statements (length/8).
* So, for now, we fake it using two separate components.
*/
static void
{
}
/*
* samr_set_user_password
*
* Set the initial password for the user.
*
* Returns 0 if everything goes well, -1 if there is trouble generating a
* key.
*/
static int
{
unsigned char nt_key[SMBAUTH_SESSION_KEY_SZ];
char hostname[64];
/*
* The new password is going to be
* the hostname in lower case.
*/
return (-1);
(void) utf8_strlwr(hostname);
return (-1);
/*
* Generate the OEM password from the hostname and the user session
* key(nt_key).
*/
/*LINTED E_BAD_PTR_CAST_ALIGN*/
return (0);
}