mirror of
https://github.com/reactos/reactos.git
synced 2025-01-02 20:43:18 +00:00
[LSASRV]
- Implement LsarDeleteObject. - Store the object name in the database object in order to be able to delete the objects key later. svn path=/trunk/; revision=57769
This commit is contained in:
parent
bff31ec33b
commit
3ba8c1dc0b
3 changed files with 104 additions and 3 deletions
|
@ -796,7 +796,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
|
||||||
|
|
||||||
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
|
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
sizeof(LSA_DB_OBJECT));
|
sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR));
|
||||||
if (NewObject == NULL)
|
if (NewObject == NULL)
|
||||||
{
|
{
|
||||||
NtClose(ObjectKeyHandle);
|
NtClose(ObjectKeyHandle);
|
||||||
|
@ -809,6 +809,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
|
||||||
NewObject->Access = DesiredAccess;
|
NewObject->Access = DesiredAccess;
|
||||||
NewObject->KeyHandle = ObjectKeyHandle;
|
NewObject->KeyHandle = ObjectKeyHandle;
|
||||||
NewObject->ParentObject = ParentObject;
|
NewObject->ParentObject = ParentObject;
|
||||||
|
wcscpy(NewObject->Name, ObjectName);
|
||||||
|
|
||||||
if (ParentObject != NULL)
|
if (ParentObject != NULL)
|
||||||
ParentObject->RefCount++;
|
ParentObject->RefCount++;
|
||||||
|
@ -895,6 +896,69 @@ LsapCloseDbObject(PLSA_DB_OBJECT DbObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject)
|
||||||
|
{
|
||||||
|
PLSA_DB_OBJECT ParentObject = NULL;
|
||||||
|
WCHAR KeyName[64];
|
||||||
|
ULONG EnumIndex;
|
||||||
|
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
DbObject->RefCount--;
|
||||||
|
|
||||||
|
if (DbObject->RefCount > 0)
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
|
if (DbObject->KeyHandle != NULL)
|
||||||
|
{
|
||||||
|
EnumIndex = 0;
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
Status = LsapRegEnumerateSubKey(DbObject->KeyHandle,
|
||||||
|
EnumIndex,
|
||||||
|
64 * sizeof(WCHAR),
|
||||||
|
KeyName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
break;
|
||||||
|
|
||||||
|
TRACE("EnumIndex: %lu\n", EnumIndex);
|
||||||
|
TRACE("Key name: %S\n", KeyName);
|
||||||
|
|
||||||
|
Status = LsapRegDeleteKey(DbObject->KeyHandle,
|
||||||
|
KeyName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// EnumIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtClose(DbObject->KeyHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DbObject->ParentObject != NULL)
|
||||||
|
{
|
||||||
|
ParentObject = DbObject->ParentObject;
|
||||||
|
|
||||||
|
LsapRegDeleteKey(ParentObject->KeyHandle,
|
||||||
|
DbObject->Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject);
|
||||||
|
|
||||||
|
if (ParentObject != NULL)
|
||||||
|
{
|
||||||
|
ParentObject->RefCount--;
|
||||||
|
|
||||||
|
if (ParentObject->RefCount == 0)
|
||||||
|
Status = LsapCloseDbObject(ParentObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
||||||
LPWSTR AttributeName,
|
LPWSTR AttributeName,
|
||||||
|
|
|
@ -1968,8 +1968,41 @@ NTSTATUS WINAPI LsarLookupPrivilegeDisplayName(
|
||||||
NTSTATUS WINAPI LsarDeleteObject(
|
NTSTATUS WINAPI LsarDeleteObject(
|
||||||
LSAPR_HANDLE *ObjectHandle)
|
LSAPR_HANDLE *ObjectHandle)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PLSA_DB_OBJECT DbObject;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
TRACE("(%p)\n", ObjectHandle);
|
||||||
|
|
||||||
|
if (ObjectHandle == NULL)
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
/* Validate the ObjectHandle */
|
||||||
|
Status = LsapValidateDbObject(*ObjectHandle,
|
||||||
|
LsaDbIgnoreObject,
|
||||||
|
DELETE,
|
||||||
|
&DbObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* You cannot delete the policy object */
|
||||||
|
if (DbObject->ObjectType == LsaDbPolicyObject)
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
/* Delete the database object */
|
||||||
|
Status = LsapDeleteDbObject(DbObject);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("LsapDeleteDbObject returned 0x%08lx\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invalidate the object handle */
|
||||||
|
*ObjectHandle = NULL;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ typedef struct _LSA_DB_OBJECT
|
||||||
ACCESS_MASK Access;
|
ACCESS_MASK Access;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
struct _LSA_DB_OBJECT *ParentObject;
|
struct _LSA_DB_OBJECT *ParentObject;
|
||||||
|
WCHAR Name[0];
|
||||||
} LSA_DB_OBJECT, *PLSA_DB_OBJECT;
|
} LSA_DB_OBJECT, *PLSA_DB_OBJECT;
|
||||||
|
|
||||||
#define LSAP_DB_SIGNATURE 0x12345678
|
#define LSAP_DB_SIGNATURE 0x12345678
|
||||||
|
@ -106,6 +107,9 @@ LsapValidateDbObject(IN LSAPR_HANDLE Handle,
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject);
|
LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
||||||
LPWSTR AttributeName,
|
LPWSTR AttributeName,
|
||||||
|
|
Loading…
Reference in a new issue