Author: ekohl
Date: Sun Nov 25 19:47:54 2012
New Revision: 57769
URL:
http://svn.reactos.org/svn/reactos?rev=57769&view=rev
Log:
[LSASRV]
- Implement LsarDeleteObject.
- Store the object name in the database object in order to be able to delete the objects
key later.
Modified:
trunk/reactos/dll/win32/lsasrv/database.c
trunk/reactos/dll/win32/lsasrv/lsarpc.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
Modified: trunk/reactos/dll/win32/lsasrv/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/database.…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] Sun Nov 25 19:47:54 2012
@@ -796,7 +796,7 @@
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
0,
- sizeof(LSA_DB_OBJECT));
+ sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) +
sizeof(WCHAR));
if (NewObject == NULL)
{
NtClose(ObjectKeyHandle);
@@ -809,6 +809,7 @@
NewObject->Access = DesiredAccess;
NewObject->KeyHandle = ObjectKeyHandle;
NewObject->ParentObject = ParentObject;
+ wcscpy(NewObject->Name, ObjectName);
if (ParentObject != NULL)
ParentObject->RefCount++;
@@ -880,6 +881,69 @@
if (DbObject->ParentObject != NULL)
ParentObject = DbObject->ParentObject;
+
+ RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject);
+
+ if (ParentObject != NULL)
+ {
+ ParentObject->RefCount--;
+
+ if (ParentObject->RefCount == 0)
+ Status = LsapCloseDbObject(ParentObject);
+ }
+
+ return Status;
+}
+
+
+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);
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Sun Nov 25 19:47:54 2012
@@ -1968,8 +1968,41 @@
NTSTATUS WINAPI LsarDeleteObject(
LSAPR_HANDLE *ObjectHandle)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PLSA_DB_OBJECT DbObject;
+ 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;
}
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sun Nov 25 19:47:54 2012
@@ -48,6 +48,7 @@
ACCESS_MASK Access;
HANDLE KeyHandle;
struct _LSA_DB_OBJECT *ParentObject;
+ WCHAR Name[0];
} LSA_DB_OBJECT, *PLSA_DB_OBJECT;
#define LSAP_DB_SIGNATURE 0x12345678
@@ -105,6 +106,9 @@
NTSTATUS
LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject);
+
+NTSTATUS
+LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject);
NTSTATUS
LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,