mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:06:34 +00:00
[SAMLIB][SAMSRV][SYSSETUP]
- Implement SamSetInformationDomain.DomainNameInformation and SamrSetInformationDomain.DomainNameInformation. - Set the account domain name for SAM too. - Remove the old samlib.h file. svn path=/trunk/; revision=56687
This commit is contained in:
parent
b62d985805
commit
e624236fa1
8 changed files with 139 additions and 48 deletions
|
@ -291,6 +291,33 @@ SamQueryInformationUser(IN SAM_HANDLE UserHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
SamSetInformationDomain(IN SAM_HANDLE DomainHandle,
|
||||||
|
IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
|
||||||
|
IN PVOID DomainInformation)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
TRACE("SamSetInformationDomain(%p %lu %p)\n",
|
||||||
|
DomainHandle, DomainInformationClass, DomainInformation);
|
||||||
|
|
||||||
|
RpcTryExcept
|
||||||
|
{
|
||||||
|
Status = SamrSetInformationDomain((SAMPR_HANDLE)DomainHandle,
|
||||||
|
DomainInformationClass,
|
||||||
|
DomainInformation);
|
||||||
|
}
|
||||||
|
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
Status = I_RpcMapWin32Status(RpcExceptionCode());
|
||||||
|
}
|
||||||
|
RpcEndExcept;
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
@ stub SamRemoveMultipleMembersFromAlias
|
@ stub SamRemoveMultipleMembersFromAlias
|
||||||
@ stub SamRidToSid
|
@ stub SamRidToSid
|
||||||
@ stub SamSetInformationAlias
|
@ stub SamSetInformationAlias
|
||||||
@ stub SamSetInformationDomain
|
@ stdcall SamSetInformationDomain(ptr long ptr)
|
||||||
@ stub SamSetInformationGroup
|
@ stub SamSetInformationGroup
|
||||||
@ stdcall SamSetInformationUser(ptr long ptr)
|
@ stdcall SamSetInformationUser(ptr long ptr)
|
||||||
@ stub SamSetMemberAttributesOfGroup
|
@ stub SamSetMemberAttributesOfGroup
|
||||||
|
|
|
@ -359,6 +359,21 @@ SamrQueryInformationDomain(IN SAMPR_HANDLE DomainHandle,
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
SampSetDomainName(PSAM_DB_OBJECT DomainObject,
|
||||||
|
PSAMPR_DOMAIN_NAME_INFORMATION DomainNameInfo)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = SampSetObjectAttribute(DomainObject,
|
||||||
|
L"Name",
|
||||||
|
REG_SZ,
|
||||||
|
DomainNameInfo->DomainName.Buffer,
|
||||||
|
DomainNameInfo->DomainName.Length + sizeof(WCHAR));
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/* Function 9 */
|
/* Function 9 */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -366,8 +381,32 @@ SamrSetInformationDomain(IN SAMPR_HANDLE DomainHandle,
|
||||||
IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
|
IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
|
||||||
IN PSAMPR_DOMAIN_INFO_BUFFER DomainInformation)
|
IN PSAMPR_DOMAIN_INFO_BUFFER DomainInformation)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PSAM_DB_OBJECT DomainObject;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
TRACE("SamrSetInformationDomain(%p %lu %p)\n",
|
||||||
|
DomainHandle, DomainInformationClass, DomainInformation);
|
||||||
|
|
||||||
|
/* Validate the server handle */
|
||||||
|
Status = SampValidateDbObject(DomainHandle,
|
||||||
|
SamDbDomainObject,
|
||||||
|
DOMAIN_WRITE_OTHER_PARAMETERS,
|
||||||
|
&DomainObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
switch (DomainInformationClass)
|
||||||
|
{
|
||||||
|
case DomainNameInformation:
|
||||||
|
Status = SampSetDomainName(DomainObject,
|
||||||
|
(PSAMPR_DOMAIN_NAME_INFORMATION)DomainInformation);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function 10 */
|
/* Function 10 */
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <samlib/samlib.h>
|
|
||||||
#include <syssetup/syssetup.h>
|
#include <syssetup/syssetup.h>
|
||||||
#include <userenv.h>
|
#include <userenv.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
@ -24,6 +23,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ntlsa.h>
|
#include <ntlsa.h>
|
||||||
#include <ntsecapi.h>
|
#include <ntsecapi.h>
|
||||||
|
#include <ntsam.h>
|
||||||
#include <sddl.h>
|
#include <sddl.h>
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
|
@ -24,6 +24,11 @@ SetAccountDomain(LPCWSTR DomainName,
|
||||||
POLICY_ACCOUNT_DOMAIN_INFO Info;
|
POLICY_ACCOUNT_DOMAIN_INFO Info;
|
||||||
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
LSA_HANDLE PolicyHandle;
|
LSA_HANDLE PolicyHandle;
|
||||||
|
|
||||||
|
SAM_HANDLE ServerHandle = NULL;
|
||||||
|
SAM_HANDLE DomainHandle = NULL;
|
||||||
|
DOMAIN_NAME_INFORMATION DomainNameInfo;
|
||||||
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT1("SYSSETUP: SetAccountDomain\n");
|
DPRINT1("SYSSETUP: SetAccountDomain\n");
|
||||||
|
@ -85,6 +90,40 @@ SetAccountDomain(LPCWSTR DomainName,
|
||||||
|
|
||||||
LsaClose(PolicyHandle);
|
LsaClose(PolicyHandle);
|
||||||
|
|
||||||
|
DomainNameInfo.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
|
||||||
|
DomainNameInfo.DomainName.MaximumLength = (wcslen(DomainName) + 1) * sizeof(WCHAR);
|
||||||
|
DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName;
|
||||||
|
|
||||||
|
Status = SamConnect(NULL,
|
||||||
|
&ServerHandle,
|
||||||
|
SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
|
||||||
|
NULL);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = SamOpenDomain(ServerHandle,
|
||||||
|
DOMAIN_WRITE_OTHER_PARAMETERS,
|
||||||
|
Info.DomainSid,
|
||||||
|
&DomainHandle);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = SamSetInformationDomain(DomainHandle,
|
||||||
|
DomainNameInformation,
|
||||||
|
(PVOID)&DomainNameInfo);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SamSetInformationDomain failed (Status: 0x%08lx)\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
SamCloseHandle(DomainHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("SamOpenDomain failed (Status: 0x%08lx)\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
SamCloseHandle(ServerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,28 @@ extern "C" {
|
||||||
|
|
||||||
typedef PVOID SAM_HANDLE, *PSAM_HANDLE;
|
typedef PVOID SAM_HANDLE, *PSAM_HANDLE;
|
||||||
|
|
||||||
|
typedef enum _DOMAIN_INFORMATION_CLASS
|
||||||
|
{
|
||||||
|
DomainPasswordInformation = 1,
|
||||||
|
DomainGeneralInformation,
|
||||||
|
DomainLogoffInformation,
|
||||||
|
DomainOemInformation,
|
||||||
|
DomainNameInformation,
|
||||||
|
DomainReplicationInformation,
|
||||||
|
DomainServerRoleInformation,
|
||||||
|
DomainModifiedInformation,
|
||||||
|
DomainStateInformation,
|
||||||
|
DomainUasInformation,
|
||||||
|
DomainGeneralInformation2,
|
||||||
|
DomainLockoutInformation,
|
||||||
|
DomainModifiedInformation2
|
||||||
|
} DOMAIN_INFORMATION_CLASS;
|
||||||
|
|
||||||
|
typedef struct _DOMAIN_NAME_INFORMATION
|
||||||
|
{
|
||||||
|
UNICODE_STRING DomainName;
|
||||||
|
} DOMAIN_NAME_INFORMATION, *PDOMAIN_NAME_INFORMATION;
|
||||||
|
|
||||||
typedef enum _USER_INFORMATION_CLASS
|
typedef enum _USER_INFORMATION_CLASS
|
||||||
{
|
{
|
||||||
UserGeneralInformation = 1,
|
UserGeneralInformation = 1,
|
||||||
|
@ -128,6 +150,12 @@ SamQueryInformationUser(IN SAM_HANDLE UserHandle,
|
||||||
IN USER_INFORMATION_CLASS UserInformationClass,
|
IN USER_INFORMATION_CLASS UserInformationClass,
|
||||||
OUT PVOID *Buffer);
|
OUT PVOID *Buffer);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
SamSetInformationDomain(IN SAM_HANDLE DomainHandle,
|
||||||
|
IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
|
||||||
|
IN PVOID DomainInformation);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
SamSetInformationUser(IN SAM_HANDLE UserHandle,
|
||||||
|
|
|
@ -233,6 +233,7 @@ typedef struct _SAMPR_DOMAIN_LOCKOUT_INFORMATION
|
||||||
unsigned short LockoutThreshold;
|
unsigned short LockoutThreshold;
|
||||||
} SAMPR_DOMAIN_LOCKOUT_INFORMATION, *PSAMPR_DOMAIN_LOCKOUT_INFORMATION;
|
} SAMPR_DOMAIN_LOCKOUT_INFORMATION, *PSAMPR_DOMAIN_LOCKOUT_INFORMATION;
|
||||||
|
|
||||||
|
cpp_quote("#ifndef _NTSAM_")
|
||||||
typedef enum _DOMAIN_INFORMATION_CLASS
|
typedef enum _DOMAIN_INFORMATION_CLASS
|
||||||
{
|
{
|
||||||
DomainPasswordInformation = 1,
|
DomainPasswordInformation = 1,
|
||||||
|
@ -248,6 +249,7 @@ typedef enum _DOMAIN_INFORMATION_CLASS
|
||||||
DomainLockoutInformation = 12,
|
DomainLockoutInformation = 12,
|
||||||
DomainModifiedInformation2 = 13
|
DomainModifiedInformation2 = 13
|
||||||
} DOMAIN_INFORMATION_CLASS;
|
} DOMAIN_INFORMATION_CLASS;
|
||||||
|
cpp_quote("#endif")
|
||||||
|
|
||||||
typedef [switch_type(DOMAIN_INFORMATION_CLASS)] union _SAMPR_DOMAIN_INFO_BUFFER
|
typedef [switch_type(DOMAIN_INFORMATION_CLASS)] union _SAMPR_DOMAIN_INFO_BUFFER
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/* $Id$
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* samlib.h
|
|
||||||
*
|
|
||||||
* Security Account Manager API, native interface
|
|
||||||
*
|
|
||||||
* This file is part of the ReactOS Operating System.
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Created by Eric Kohl
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
||||||
*
|
|
||||||
* This source code is offered for use in the public domain. You may
|
|
||||||
* use, modify or distribute it freely.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful but
|
|
||||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
||||||
* DISCLAMED. This includes but is not limited to warranties of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SAMLIB_H_INCLUDED__
|
|
||||||
#define __SAMLIB_H_INCLUDED__
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WINAPI
|
|
||||||
SamCreateUser (PWSTR UserName,
|
|
||||||
PWSTR UserPassword,
|
|
||||||
PSID UserSid);
|
|
||||||
|
|
||||||
BOOL WINAPI
|
|
||||||
SamCheckUserPassword (PWSTR UserName,
|
|
||||||
PWSTR UserPassword);
|
|
||||||
|
|
||||||
BOOL WINAPI
|
|
||||||
SamGetUserSid (PWSTR UserName,
|
|
||||||
PSID *Sid);
|
|
||||||
|
|
||||||
#endif /* __SAMLIB_H_INCLUDED__ */
|
|
||||||
|
|
||||||
/* EOF */
|
|
Loading…
Add table
Add a link
Reference in a new issue