- 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:
Eric Kohl 2012-11-25 19:47:54 +00:00
parent bff31ec33b
commit 3ba8c1dc0b
3 changed files with 104 additions and 3 deletions

View file

@ -796,7 +796,7 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
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 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
NewObject->Access = DesiredAccess;
NewObject->KeyHandle = ObjectKeyHandle;
NewObject->ParentObject = ParentObject;
wcscpy(NewObject->Name, ObjectName);
if (ParentObject != NULL)
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
LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject,
LPWSTR AttributeName,

View file

@ -1968,8 +1968,41 @@ NTSTATUS WINAPI LsarLookupPrivilegeDisplayName(
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;
}

View file

@ -48,6 +48,7 @@ typedef struct _LSA_DB_OBJECT
ACCESS_MASK Access;
HANDLE KeyHandle;
struct _LSA_DB_OBJECT *ParentObject;
WCHAR Name[0];
} LSA_DB_OBJECT, *PLSA_DB_OBJECT;
#define LSAP_DB_SIGNATURE 0x12345678
@ -106,6 +107,9 @@ LsapValidateDbObject(IN LSAPR_HANDLE Handle,
NTSTATUS
LsapCloseDbObject(IN PLSA_DB_OBJECT DbObject);
NTSTATUS
LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject);
NTSTATUS
LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,
LPWSTR AttributeName,