WINE_DEFAULT_DEBUG_CHANNEL(advapi);
-static DWORD ComputeStringSidSize(LPCWSTR StringSid);
static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes);
-#define MAX_GUID_STRING_LEN 39
-
-BOOL WINAPI
-AddAuditAccessAceEx(PACL pAcl,
- DWORD dwAceRevision,
- DWORD AceFlags,
- DWORD dwAccessMask,
- PSID pSid,
- BOOL bAuditSuccess,
- BOOL bAuditFailure);
-
-typedef struct RECORD
+typedef struct _ACEFLAG
{
- LPCWSTR key;
- DWORD value;
-} RECORD;
-
+ LPCWSTR wstr;
+ DWORD value;
+} ACEFLAG, *LPACEFLAG;
typedef struct _MAX_SID
{
MAX_SID Sid;
} WELLKNOWNSID;
-typedef struct _ACEFLAG
-{
- LPCWSTR wstr;
- DWORD value;
-} ACEFLAG, *LPACEFLAG;
-
static const WELLKNOWNSID WellKnownSids[] =
{
{ {0,0}, WinNullSid, { SID_REVISION, 1, { SECURITY_NULL_SID_AUTHORITY }, { SECURITY_NULL_RID } } },
{ {'S','I'}, WinSystemLabelSid, { SID_REVISION, 1, { SECURITY_MANDATORY_LABEL_AUTHORITY}, { SECURITY_MANDATORY_SYSTEM_RID } } },
};
+/* these SIDs must be constructed as relative to some domain - only the RID is well-known */
typedef struct WELLKNOWNRID
{
+ WCHAR wstr[2];
WELL_KNOWN_SID_TYPE Type;
DWORD Rid;
} WELLKNOWNRID;
static const WELLKNOWNRID WellKnownRids[] = {
- { WinAccountAdministratorSid, DOMAIN_USER_RID_ADMIN },
- { WinAccountGuestSid, DOMAIN_USER_RID_GUEST },
- { WinAccountKrbtgtSid, DOMAIN_USER_RID_KRBTGT },
- { WinAccountDomainAdminsSid, DOMAIN_GROUP_RID_ADMINS },
- { WinAccountDomainUsersSid, DOMAIN_GROUP_RID_USERS },
- { WinAccountDomainGuestsSid, DOMAIN_GROUP_RID_GUESTS },
- { WinAccountComputersSid, DOMAIN_GROUP_RID_COMPUTERS },
- { WinAccountControllersSid, DOMAIN_GROUP_RID_CONTROLLERS },
- { WinAccountCertAdminsSid, DOMAIN_GROUP_RID_CERT_ADMINS },
- { WinAccountSchemaAdminsSid, DOMAIN_GROUP_RID_SCHEMA_ADMINS },
- { WinAccountEnterpriseAdminsSid, DOMAIN_GROUP_RID_ENTERPRISE_ADMINS },
- { WinAccountPolicyAdminsSid, DOMAIN_GROUP_RID_POLICY_ADMINS },
- { WinAccountRasAndIasServersSid, DOMAIN_ALIAS_RID_RAS_SERVERS },
+ { {'L','A'}, WinAccountAdministratorSid, DOMAIN_USER_RID_ADMIN },
+ { {'L','G'}, WinAccountGuestSid, DOMAIN_USER_RID_GUEST },
+ { {0,0}, WinAccountKrbtgtSid, DOMAIN_USER_RID_KRBTGT },
+ { {'D','A'}, WinAccountDomainAdminsSid, DOMAIN_GROUP_RID_ADMINS },
+ { {'D','U'}, WinAccountDomainUsersSid, DOMAIN_GROUP_RID_USERS },
+ { {'D','G'}, WinAccountDomainGuestsSid, DOMAIN_GROUP_RID_GUESTS },
+ { {'D','C'}, WinAccountComputersSid, DOMAIN_GROUP_RID_COMPUTERS },
+ { {'D','D'}, WinAccountControllersSid, DOMAIN_GROUP_RID_CONTROLLERS },
+ { {'C','A'}, WinAccountCertAdminsSid, DOMAIN_GROUP_RID_CERT_ADMINS },
+ { {'S','A'}, WinAccountSchemaAdminsSid, DOMAIN_GROUP_RID_SCHEMA_ADMINS },
+ { {'E','A'}, WinAccountEnterpriseAdminsSid, DOMAIN_GROUP_RID_ENTERPRISE_ADMINS },
+ { {'P','A'}, WinAccountPolicyAdminsSid, DOMAIN_GROUP_RID_POLICY_ADMINS },
+ { {'R','S'}, WinAccountRasAndIasServersSid, DOMAIN_ALIAS_RID_RAS_SERVERS },
};
+#ifndef __REACTOS__
static const SID sidWorld = { SID_REVISION, 1, { SECURITY_WORLD_SID_AUTHORITY} , { SECURITY_WORLD_RID } };
+#endif
+
+static const WCHAR SDDL_NO_READ_UP[] = {'N','R',0};
+static const WCHAR SDDL_NO_WRITE_UP[] = {'N','W',0};
+static const WCHAR SDDL_NO_EXECUTE_UP[] = {'N','X',0};
/*
* ACE types
*/
static const WCHAR SDDL_ACCESS_ALLOWED[] = {'A',0};
static const WCHAR SDDL_ACCESS_DENIED[] = {'D',0};
+#ifndef __REACTOS__
static const WCHAR SDDL_OBJECT_ACCESS_ALLOWED[] = {'O','A',0};
static const WCHAR SDDL_OBJECT_ACCESS_DENIED[] = {'O','D',0};
+#endif
static const WCHAR SDDL_AUDIT[] = {'A','U',0};
static const WCHAR SDDL_ALARM[] = {'A','L',0};
+static const WCHAR SDDL_MANDATORY_LABEL[] = {'M','L',0};
+#ifndef __REACTOS__
static const WCHAR SDDL_OBJECT_AUDIT[] = {'O','U',0};
static const WCHAR SDDL_OBJECT_ALARM[] = {'O','L',0};
+#endif
/*
* SDDL ADS Rights
return "(too-big)";
}
-static const ACEFLAG AceRights[] =
-{
- { SDDL_GENERIC_ALL, GENERIC_ALL },
- { SDDL_GENERIC_READ, GENERIC_READ },
- { SDDL_GENERIC_WRITE, GENERIC_WRITE },
- { SDDL_GENERIC_EXECUTE, GENERIC_EXECUTE },
-
- { SDDL_READ_CONTROL, READ_CONTROL },
- { SDDL_STANDARD_DELETE, DELETE },
- { SDDL_WRITE_DAC, WRITE_DAC },
- { SDDL_WRITE_OWNER, WRITE_OWNER },
-
- { SDDL_READ_PROPERTY, ADS_RIGHT_DS_READ_PROP},
- { SDDL_WRITE_PROPERTY, ADS_RIGHT_DS_WRITE_PROP},
- { SDDL_CREATE_CHILD, ADS_RIGHT_DS_CREATE_CHILD},
- { SDDL_DELETE_CHILD, ADS_RIGHT_DS_DELETE_CHILD},
- { SDDL_LIST_CHILDREN, ADS_RIGHT_ACTRL_DS_LIST},
- { SDDL_SELF_WRITE, ADS_RIGHT_DS_SELF},
- { SDDL_LIST_OBJECT, ADS_RIGHT_DS_LIST_OBJECT},
- { SDDL_DELETE_TREE, ADS_RIGHT_DS_DELETE_TREE},
- { SDDL_CONTROL_ACCESS, ADS_RIGHT_DS_CONTROL_ACCESS},
-
- { SDDL_FILE_ALL, FILE_ALL_ACCESS },
- { SDDL_FILE_READ, FILE_GENERIC_READ },
- { SDDL_FILE_WRITE, FILE_GENERIC_WRITE },
- { SDDL_FILE_EXECUTE, FILE_GENERIC_EXECUTE },
-
- { SDDL_KEY_ALL, KEY_ALL_ACCESS },
- { SDDL_KEY_READ, KEY_READ },
- { SDDL_KEY_WRITE, KEY_WRITE },
- { SDDL_KEY_EXECUTE, KEY_EXECUTE },
- { NULL, 0 },
-};
-
/* set last error code from NT status and get the proper boolean return value */
/* used for functions that are a simple wrapper around the corresponding ntdll API */
static __inline BOOL set_ntstatus( NTSTATUS status )
return NT_SUCCESS(status);
}
-static const RECORD SidTable[] =
-{
- { SDDL_ACCOUNT_OPERATORS, WinBuiltinAccountOperatorsSid },
- { SDDL_ALIAS_PREW2KCOMPACC, WinBuiltinPreWindows2000CompatibleAccessSid },
- { SDDL_ANONYMOUS, WinAnonymousSid },
- { SDDL_AUTHENTICATED_USERS, WinAuthenticatedUserSid },
- { SDDL_BUILTIN_ADMINISTRATORS, WinBuiltinAdministratorsSid },
- { SDDL_BUILTIN_GUESTS, WinBuiltinGuestsSid },
- { SDDL_BACKUP_OPERATORS, WinBuiltinBackupOperatorsSid },
- { SDDL_BUILTIN_USERS, WinBuiltinUsersSid },
- { SDDL_CERT_SERV_ADMINISTRATORS, WinAccountCertAdminsSid /* FIXME: DOMAIN_GROUP_RID_CERT_ADMINS */ },
- { SDDL_CREATOR_GROUP, WinCreatorGroupSid },
- { SDDL_CREATOR_OWNER, WinCreatorOwnerSid },
- { SDDL_DOMAIN_ADMINISTRATORS, WinAccountDomainAdminsSid /* FIXME: DOMAIN_GROUP_RID_ADMINS */ },
- { SDDL_DOMAIN_COMPUTERS, WinAccountComputersSid /* FIXME: DOMAIN_GROUP_RID_COMPUTERS */ },
- { SDDL_DOMAIN_DOMAIN_CONTROLLERS, WinAccountControllersSid /* FIXME: DOMAIN_GROUP_RID_CONTROLLERS */ },
- { SDDL_DOMAIN_GUESTS, WinAccountDomainGuestsSid /* FIXME: DOMAIN_GROUP_RID_GUESTS */ },
- { SDDL_DOMAIN_USERS, WinAccountDomainUsersSid /* FIXME: DOMAIN_GROUP_RID_USERS */ },
- { SDDL_ENTERPRISE_ADMINS, WinAccountEnterpriseAdminsSid /* FIXME: DOMAIN_GROUP_RID_ENTERPRISE_ADMINS */ },
- { SDDL_ENTERPRISE_DOMAIN_CONTROLLERS, WinEnterpriseControllersSid },
- { SDDL_EVERYONE, WinWorldSid },
- { SDDL_GROUP_POLICY_ADMINS, WinAccountPolicyAdminsSid /* FIXME: DOMAIN_GROUP_RID_POLICY_ADMINS */ },
- { SDDL_INTERACTIVE, WinInteractiveSid },
- { SDDL_LOCAL_ADMIN, WinAccountAdministratorSid /* FIXME: DOMAIN_USER_RID_ADMIN */ },
- { SDDL_LOCAL_GUEST, WinAccountGuestSid /* FIXME: DOMAIN_USER_RID_GUEST */ },
- { SDDL_LOCAL_SERVICE, WinLocalServiceSid },
- { SDDL_LOCAL_SYSTEM, WinLocalSystemSid },
- { SDDL_NETWORK, WinNetworkSid },
- { SDDL_NETWORK_CONFIGURATION_OPS, WinBuiltinNetworkConfigurationOperatorsSid },
- { SDDL_NETWORK_SERVICE, WinNetworkServiceSid },
- { SDDL_PRINTER_OPERATORS, WinBuiltinPrintOperatorsSid },
- { SDDL_PERSONAL_SELF, WinSelfSid },
- { SDDL_POWER_USERS, WinBuiltinPowerUsersSid },
- { SDDL_RAS_SERVERS, WinAccountRasAndIasServersSid /* FIXME: DOMAIN_ALIAS_RID_RAS_SERVERS */ },
- { SDDL_REMOTE_DESKTOP, WinBuiltinRemoteDesktopUsersSid },
- { SDDL_REPLICATOR, WinBuiltinReplicatorSid },
- { SDDL_RESTRICTED_CODE, WinRestrictedCodeSid },
- { SDDL_SCHEMA_ADMINISTRATORS, WinAccountSchemaAdminsSid /* FIXME: DOMAIN_GROUP_RID_SCHEMA_ADMINS */ },
- { SDDL_SERVER_OPERATORS, WinBuiltinSystemOperatorsSid },
- { SDDL_SERVICE, WinServiceSid },
- { NULL, 0 },
-};
+static LPWSTR SERV_dup( LPCSTR str )
+{
+ UINT len;
+ LPWSTR wstr;
+
+ if( !str )
+ return NULL;
+ len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ wstr = heap_alloc( len*sizeof (WCHAR) );
+ MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, len );
+ return wstr;
+}
/************************************************************
* ADVAPI_IsLocalComputer
return Result;
}
+/************************************************************
+ * ADVAPI_GetComputerSid
+ */
+BOOL ADVAPI_GetComputerSid(PSID sid)
+{
+ static const struct /* same fields as struct SID */
+ {
+ BYTE Revision;
+ BYTE SubAuthorityCount;
+ SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
+ DWORD SubAuthority[4];
+ } computer_sid =
+ { SID_REVISION, 4, { SECURITY_NT_AUTHORITY }, { SECURITY_NT_NON_UNIQUE, 0, 0, 0 } };
+
+ memcpy( sid, &computer_sid, sizeof(computer_sid) );
+ return TRUE;
+}
+
/* Exported functions */
/*
return TRUE;
}
-/*
- * @implemented
+/******************************************************************************
+ * OpenThreadToken [ADVAPI32.@]
+ *
+ * Opens the access token associated with a thread handle.
+ *
+ * PARAMS
+ * ThreadHandle [I] Handle to process
+ * DesiredAccess [I] Desired access to the thread
+ * OpenAsSelf [I] ???
+ * TokenHandle [O] Destination for the token handle
+ *
+ * RETURNS
+ * Success: TRUE. TokenHandle contains the access token.
+ * Failure: FALSE.
+ *
+ * NOTES
+ * See NtOpenThreadToken.
*/
BOOL WINAPI
-OpenThreadToken(HANDLE ThreadHandle,
- DWORD DesiredAccess,
- BOOL OpenAsSelf,
- PHANDLE TokenHandle)
+OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
+ BOOL OpenAsSelf, HANDLE *TokenHandle)
{
- NTSTATUS Status;
-
- Status = NtOpenThreadToken(ThreadHandle,
- DesiredAccess,
- OpenAsSelf,
- TokenHandle);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
+ return set_ntstatus( NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
}
/*
PHANDLE newToken)
{
TOKEN_TYPE type;
- SECURITY_IMPERSONATION_LEVEL level = TokenImpersonationLevel;
+ SECURITY_IMPERSONATION_LEVEL level = SecurityAnonymous;
DWORD size;
FIXME("(%p, 0x%x, %u, %p, %u, %p, %u, %p, %p): stub\n",
return RtlFreeSid(pSid);
}
-/*
- * @implemented
+/******************************************************************************
+ * CopySid [ADVAPI32.@]
+ *
+ * PARAMS
+ * nDestinationSidLength []
+ * pDestinationSid []
+ * pSourceSid []
*/
BOOL WINAPI
-CopySid(DWORD nDestinationSidLength,
- PSID pDestinationSid,
- PSID pSourceSid)
+CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
{
- NTSTATUS Status;
-
- Status = RtlCopySid(nDestinationSidLength,
- pDestinationSid,
- pSourceSid);
- if (!NT_SUCCESS (Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
+ return set_ntstatus(RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid));
}
/*
return TRUE;
}
-/*
- * @implemented
+/******************************************************************************
+ * DeleteAce [ADVAPI32.@]
*/
-BOOL
-WINAPI
-DeleteAce(PACL pAcl,
- DWORD dwAceIndex)
+BOOL WINAPI DeleteAce(PACL pAcl, DWORD dwAceIndex)
{
- NTSTATUS Status;
-
- Status = RtlDeleteAce(pAcl,
- dwAceIndex);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
+ return set_ntstatus(RtlDeleteAce(pAcl, dwAceIndex));
}
/*
(PACE*)pAce);
}
-
-/*
- * @implemented
+/******************************************************************************
+ * GetAce [ADVAPI32.@]
*/
-BOOL
-WINAPI
-GetAce(PACL pAcl,
- DWORD dwAceIndex,
- LPVOID *pAce)
+BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
{
- NTSTATUS Status;
-
- Status = RtlGetAce(pAcl,
- dwAceIndex,
- pAce);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
+ return set_ntstatus(RtlGetAce(pAcl, dwAceIndex, pAce));
}
-/*
- * @implemented
+/******************************************************************************
+ * GetAclInformation [ADVAPI32.@]
*/
-BOOL
-WINAPI
-GetAclInformation(PACL pAcl,
- LPVOID pAclInformation,
- DWORD nAclInformationLength,
- ACL_INFORMATION_CLASS dwAclInformationClass)
+BOOL WINAPI GetAclInformation(
+ PACL pAcl,
+ LPVOID pAclInformation,
+ DWORD nAclInformationLength,
+ ACL_INFORMATION_CLASS dwAclInformationClass)
{
- NTSTATUS Status;
-
- Status = RtlQueryInformationAcl(pAcl,
- pAclInformation,
- nAclInformationLength,
- dwAclInformationClass);
- if (!NT_SUCCESS(Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
+ return set_ntstatus(RtlQueryInformationAcl(pAcl, pAclInformation,
+ nAclInformationLength, dwAclInformationClass));
}
/*
LookupPrivilegeDisplayNameA(LPCSTR lpSystemName,
LPCSTR lpName,
LPSTR lpDisplayName,
- LPDWORD cbDisplayName,
+ LPDWORD cchDisplayName,
LPDWORD lpLanguageId)
{
- FIXME("%s() not implemented!\n", __FUNCTION__);
- SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
-}
+ UNICODE_STRING lpSystemNameW;
+ UNICODE_STRING lpNameW;
+ BOOL ret;
+ DWORD wLen = 0;
+ TRACE("%s %s %p %p %p\n", debugstr_a(lpSystemName), debugstr_a(lpName), lpName, cchDisplayName, lpLanguageId);
-/**********************************************************************
- * LookupPrivilegeDisplayNameW EXPORTED
- *
- * @unimplemented
- */
-BOOL
-WINAPI
-LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName,
- LPCWSTR lpName,
- LPWSTR lpDisplayName,
- LPDWORD cbDisplayName,
- LPDWORD lpLanguageId)
-{
- FIXME("%s() not implemented!\n", __FUNCTION__);
- SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
+ RtlCreateUnicodeStringFromAsciiz(&lpNameW, lpName);
+ ret = LookupPrivilegeDisplayNameW(lpSystemNameW.Buffer, lpNameW.Buffer, NULL, &wLen, lpLanguageId);
+ if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ LPWSTR lpDisplayNameW = HeapAlloc(GetProcessHeap(), 0, wLen * sizeof(WCHAR));
+
+ ret = LookupPrivilegeDisplayNameW(lpSystemNameW.Buffer, lpNameW.Buffer, lpDisplayNameW,
+ &wLen, lpLanguageId);
+ if (ret)
+ {
+ unsigned int len = WideCharToMultiByte(CP_ACP, 0, lpDisplayNameW, -1, lpDisplayName,
+ *cchDisplayName, NULL, NULL);
+
+ if (len == 0)
+ {
+ /* WideCharToMultiByte failed */
+ ret = FALSE;
+ }
+ else if (len > *cchDisplayName)
+ {
+ *cchDisplayName = len;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ ret = FALSE;
+ }
+ else
+ {
+ /* WideCharToMultiByte succeeded, output length needs to be
+ * length not including NULL terminator
+ */
+ *cchDisplayName = len - 1;
+ }
+ }
+ HeapFree(GetProcessHeap(), 0, lpDisplayNameW);
+ }
+ RtlFreeUnicodeString(&lpSystemNameW);
+ RtlFreeUnicodeString(&lpNameW);
+ return ret;
}
/**********************************************************************
pTrustee->ptstrName = name;
}
-/******************************************************************************
- * GetTrusteeFormW [ADVAPI32.@]
- */
-TRUSTEE_FORM WINAPI
-GetTrusteeFormA(PTRUSTEE_A pTrustee)
-{
- return pTrustee->TrusteeForm;
-}
-
-
-/******************************************************************************
- * GetTrusteeFormW [ADVAPI32.@]
- */
-TRUSTEE_FORM WINAPI
-GetTrusteeFormW(PTRUSTEE_W pTrustee)
-{
- return pTrustee->TrusteeForm;
-}
-
+/******************************************************************************
+ * GetTrusteeFormA [ADVAPI32.@]
+ */
+TRUSTEE_FORM WINAPI GetTrusteeFormA(PTRUSTEEA pTrustee)
+{
+ TRACE("(%p)\n", pTrustee);
+
+ if (!pTrustee)
+ return TRUSTEE_BAD_FORM;
+
+ return pTrustee->TrusteeForm;
+}
+
+/******************************************************************************
+ * GetTrusteeFormW [ADVAPI32.@]
+ */
+TRUSTEE_FORM WINAPI GetTrusteeFormW(PTRUSTEEW pTrustee)
+{
+ TRACE("(%p)\n", pTrustee);
+
+ if (!pTrustee)
+ return TRUSTEE_BAD_FORM;
+
+ return pTrustee->TrusteeForm;
+}
+
/******************************************************************************
* GetTrusteeNameA [ADVAPI32.@]
*/
{ SDDL_AUDIT, SYSTEM_AUDIT_ACE_TYPE },
{ SDDL_ACCESS_ALLOWED, ACCESS_ALLOWED_ACE_TYPE },
{ SDDL_ACCESS_DENIED, ACCESS_DENIED_ACE_TYPE },
+ { SDDL_MANDATORY_LABEL,SYSTEM_MANDATORY_LABEL_ACE_TYPE },
/*
{ SDDL_OBJECT_ACCESS_ALLOWED, ACCESS_ALLOWED_OBJECT_ACE_TYPE },
{ SDDL_OBJECT_ACCESS_DENIED, ACCESS_DENIED_OBJECT_ACE_TYPE },
LPCWSTR szAcl = *StringAcl;
const ACEFLAG *lpaf = AceType;
+ while (*szAcl == ' ')
+ szAcl++;
+
while (lpaf->wstr &&
(len = strlenW(lpaf->wstr)) &&
strncmpW(lpaf->wstr, szAcl, len))
if (!lpaf->wstr)
return 0;
- *StringAcl += len;
+ *StringAcl = szAcl + len;
return lpaf->value;
}
BYTE flags = 0;
LPCWSTR szAcl = *StringAcl;
+ while (*szAcl == ' ')
+ szAcl++;
+
while (*szAcl != ';')
{
const ACEFLAG *lpaf = AceFlags;
if (!lpaf->wstr)
return 0;
- flags |= lpaf->value;
+ flags |= lpaf->value;
szAcl += len;
}
/******************************************************************************
* ParseAceStringRights
*/
+static const ACEFLAG AceRights[] =
+{
+ { SDDL_GENERIC_ALL, GENERIC_ALL },
+ { SDDL_GENERIC_READ, GENERIC_READ },
+ { SDDL_GENERIC_WRITE, GENERIC_WRITE },
+ { SDDL_GENERIC_EXECUTE, GENERIC_EXECUTE },
+
+ { SDDL_READ_CONTROL, READ_CONTROL },
+ { SDDL_STANDARD_DELETE, DELETE },
+ { SDDL_WRITE_DAC, WRITE_DAC },
+ { SDDL_WRITE_OWNER, WRITE_OWNER },
+
+ { SDDL_READ_PROPERTY, ADS_RIGHT_DS_READ_PROP},
+ { SDDL_WRITE_PROPERTY, ADS_RIGHT_DS_WRITE_PROP},
+ { SDDL_CREATE_CHILD, ADS_RIGHT_DS_CREATE_CHILD},
+ { SDDL_DELETE_CHILD, ADS_RIGHT_DS_DELETE_CHILD},
+ { SDDL_LIST_CHILDREN, ADS_RIGHT_ACTRL_DS_LIST},
+ { SDDL_SELF_WRITE, ADS_RIGHT_DS_SELF},
+ { SDDL_LIST_OBJECT, ADS_RIGHT_DS_LIST_OBJECT},
+ { SDDL_DELETE_TREE, ADS_RIGHT_DS_DELETE_TREE},
+ { SDDL_CONTROL_ACCESS, ADS_RIGHT_DS_CONTROL_ACCESS},
+
+ { SDDL_FILE_ALL, FILE_ALL_ACCESS },
+ { SDDL_FILE_READ, FILE_GENERIC_READ },
+ { SDDL_FILE_WRITE, FILE_GENERIC_WRITE },
+ { SDDL_FILE_EXECUTE, FILE_GENERIC_EXECUTE },
+
+ { SDDL_KEY_ALL, KEY_ALL_ACCESS },
+ { SDDL_KEY_READ, KEY_READ },
+ { SDDL_KEY_WRITE, KEY_WRITE },
+ { SDDL_KEY_EXECUTE, KEY_EXECUTE },
+
+ { SDDL_NO_READ_UP, SYSTEM_MANDATORY_LABEL_NO_READ_UP },
+ { SDDL_NO_WRITE_UP, SYSTEM_MANDATORY_LABEL_NO_WRITE_UP },
+ { SDDL_NO_EXECUTE_UP, SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP },
+ { NULL, 0 },
+};
+
static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
{
UINT len = 0;
DWORD rights = 0;
LPCWSTR szAcl = *StringAcl;
+ while (*szAcl == ' ')
+ szAcl++;
+
if ((*szAcl == '0') && (*(szAcl + 1) == 'x'))
{
LPCWSTR p = szAcl;
- while (*p && *p != ';')
+ while (*p && *p != ';')
p++;
- if (p - szAcl <= 10 /* 8 hex digits + "0x" */ )
- {
- rights = strtoulW(szAcl, NULL, 16);
- szAcl = p;
- }
- else
+ if (p - szAcl <= 10 /* 8 hex digits + "0x" */ )
+ {
+ rights = strtoulW(szAcl, NULL, 16);
+ szAcl = p;
+ }
+ else
WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl, p - szAcl));
}
else
const ACEFLAG *lpaf = AceRights;
while (lpaf->wstr &&
- (len = strlenW(lpaf->wstr)) &&
- strncmpW(lpaf->wstr, szAcl, len))
- {
- lpaf++;
- }
+ (len = strlenW(lpaf->wstr)) &&
+ strncmpW(lpaf->wstr, szAcl, len))
+ {
+ lpaf++;
+ }
if (!lpaf->wstr)
return 0;
- rights |= lpaf->value;
+ rights |= lpaf->value;
szAcl += len;
}
}
*
* dacl_flags(string_ace1)(string_ace2)... (string_acen)
*/
-static BOOL
-ParseStringAclToAcl(LPCWSTR StringAcl,
- LPDWORD lpdwFlags,
- PACL pAcl,
- LPDWORD cBytes)
+static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
+ PACL pAcl, LPDWORD cBytes)
{
DWORD val;
DWORD sidlen;
DWORD acesize = 0;
DWORD acecount = 0;
PACCESS_ALLOWED_ACE pAce = NULL; /* pointer to current ACE */
+ DWORD error = ERROR_INVALID_ACL;
TRACE("%s\n", debugstr_w(StringAcl));
if (!StringAcl)
- return FALSE;
+ return FALSE;
if (pAcl) /* pAce is only useful if we're setting values */
pAce = (PACCESS_ALLOWED_ACE) (pAcl + 1);
/* Parse ACE type */
val = ParseAceStringType(&StringAcl);
- if (pAce)
+ if (pAce)
pAce->Header.AceType = (BYTE) val;
if (*StringAcl != ';')
+ {
+ error = RPC_S_INVALID_STRING_UUID;
goto lerr;
+ }
StringAcl++;
/* Parse ACE flags */
- val = ParseAceStringFlags(&StringAcl);
- if (pAce)
+ val = ParseAceStringFlags(&StringAcl);
+ if (pAce)
pAce->Header.AceFlags = (BYTE) val;
if (*StringAcl != ';')
goto lerr;
StringAcl++;
/* Parse ACE rights */
- val = ParseAceStringRights(&StringAcl);
- if (pAce)
+ val = ParseAceStringRights(&StringAcl);
+ if (pAce)
pAce->Mask = val;
if (*StringAcl != ';')
goto lerr;
StringAcl++;
/* Parse ACE object guid */
+ while (*StringAcl == ' ')
+ StringAcl++;
if (*StringAcl != ';')
{
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
StringAcl++;
/* Parse ACE inherit object guid */
+ while (*StringAcl == ' ')
+ StringAcl++;
if (*StringAcl != ';')
{
FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
/* Parse ACE account sid */
if (ParseStringSidToSid(StringAcl, pAce ? &pAce->SidStart : NULL, &sidlen))
- {
+ {
while (*StringAcl && *StringAcl != ')')
StringAcl++;
- }
+ }
if (*StringAcl != ')')
goto lerr;
return TRUE;
lerr:
- SetLastError(ERROR_INVALID_ACL);
+ SetLastError(error);
WARN("Invalid ACE string format\n");
return FALSE;
}
/******************************************************************************
* ParseStringSecurityDescriptorToSecurityDescriptor
*/
-static BOOL
-ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescriptor,
- SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
- LPDWORD cBytes)
+static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
+ LPCWSTR StringSecurityDescriptor,
+ SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
+ LPDWORD cBytes)
{
BOOL bret = FALSE;
WCHAR toktype;
- WCHAR tok[MAX_PATH];
+ WCHAR *tok;
LPCWSTR lptoken;
LPBYTE lpNext = NULL;
DWORD len;
*cBytes = sizeof(SECURITY_DESCRIPTOR);
+ tok = heap_alloc( (lstrlenW(StringSecurityDescriptor) + 1) * sizeof(WCHAR));
+
if (SecurityDescriptor)
lpNext = (LPBYTE)(SecurityDescriptor + 1);
+ while (*StringSecurityDescriptor == ' ')
+ StringSecurityDescriptor++;
+
while (*StringSecurityDescriptor)
{
toktype = *StringSecurityDescriptor;
- /* Expect char identifier followed by ':' */
- StringSecurityDescriptor++;
+ /* Expect char identifier followed by ':' */
+ StringSecurityDescriptor++;
if (*StringSecurityDescriptor != ':')
{
SetLastError(ERROR_INVALID_PARAMETER);
goto lend;
}
- StringSecurityDescriptor++;
+ StringSecurityDescriptor++;
- /* Extract token */
- lptoken = StringSecurityDescriptor;
- while (*lptoken && *lptoken != ':')
+ /* Extract token */
+ lptoken = StringSecurityDescriptor;
+ while (*lptoken && *lptoken != ':')
lptoken++;
- if (*lptoken)
+ if (*lptoken)
lptoken--;
len = lptoken - StringSecurityDescriptor;
tok[len] = 0;
switch (toktype)
- {
+ {
case 'O':
{
DWORD bytes;
lpNext += bytes; /* Advance to next token */
}
- *cBytes += bytes;
+ *cBytes += bytes;
break;
}
lpNext += bytes; /* Advance to next token */
}
- *cBytes += bytes;
+ *cBytes += bytes;
break;
}
case 'D':
- {
+ {
DWORD flags;
DWORD bytes;
SecurityDescriptor->Control |= SE_DACL_PRESENT | flags;
SecurityDescriptor->Dacl = lpNext - (LPBYTE)SecurityDescriptor;
lpNext += bytes; /* Advance to next token */
- }
+ }
- *cBytes += bytes;
+ *cBytes += bytes;
- break;
+ break;
}
case 'S':
SecurityDescriptor->Control |= SE_SACL_PRESENT | flags;
SecurityDescriptor->Sacl = lpNext - (LPBYTE)SecurityDescriptor;
lpNext += bytes; /* Advance to next token */
- }
+ }
- *cBytes += bytes;
+ *cBytes += bytes;
- break;
+ break;
}
default:
FIXME("Unknown token\n");
SetLastError(ERROR_INVALID_PARAMETER);
- goto lend;
- }
+ goto lend;
+ }
StringSecurityDescriptor = lptoken;
}
bret = TRUE;
lend:
+ heap_free(tok);
return bret;
}
/******************************************************************************
* ConvertSecurityDescriptorToStringSecurityDescriptorW [ADVAPI32.@]
- * @implemented
*/
-BOOL WINAPI
-ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR SecurityDescriptor,
- DWORD SDRevision,
- SECURITY_INFORMATION SecurityInformation,
- LPWSTR *OutputString,
- PULONG OutputLen)
+BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorW(PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD SDRevision, SECURITY_INFORMATION RequestedInformation, LPWSTR *OutputString, PULONG OutputLen)
{
ULONG len;
WCHAR *wptr, *wstr;
}
len = 0;
- if (SecurityInformation & OWNER_SECURITY_INFORMATION)
+ if (RequestedInformation & OWNER_SECURITY_INFORMATION)
if (!DumpOwner(SecurityDescriptor, NULL, &len))
return FALSE;
- if (SecurityInformation & GROUP_SECURITY_INFORMATION)
+ if (RequestedInformation & GROUP_SECURITY_INFORMATION)
if (!DumpGroup(SecurityDescriptor, NULL, &len))
return FALSE;
- if (SecurityInformation & DACL_SECURITY_INFORMATION)
+ if (RequestedInformation & DACL_SECURITY_INFORMATION)
if (!DumpDacl(SecurityDescriptor, NULL, &len))
return FALSE;
- if (SecurityInformation & SACL_SECURITY_INFORMATION)
+ if (RequestedInformation & SACL_SECURITY_INFORMATION)
if (!DumpSacl(SecurityDescriptor, NULL, &len))
return FALSE;
wstr = wptr = LocalAlloc(0, (len + 1)*sizeof(WCHAR));
+#ifdef __REACTOS__
if (wstr == NULL)
return FALSE;
-
- if (SecurityInformation & OWNER_SECURITY_INFORMATION)
- if (!DumpOwner(SecurityDescriptor, &wptr, NULL))
+#endif
+
+ if (RequestedInformation & OWNER_SECURITY_INFORMATION)
+ if (!DumpOwner(SecurityDescriptor, &wptr, NULL)) {
+ LocalFree (wstr);
return FALSE;
- if (SecurityInformation & GROUP_SECURITY_INFORMATION)
- if (!DumpGroup(SecurityDescriptor, &wptr, NULL))
+ }
+ if (RequestedInformation & GROUP_SECURITY_INFORMATION)
+ if (!DumpGroup(SecurityDescriptor, &wptr, NULL)) {
+ LocalFree (wstr);
return FALSE;
- if (SecurityInformation & DACL_SECURITY_INFORMATION)
- if (!DumpDacl(SecurityDescriptor, &wptr, NULL))
+ }
+ if (RequestedInformation & DACL_SECURITY_INFORMATION)
+ if (!DumpDacl(SecurityDescriptor, &wptr, NULL)) {
+ LocalFree (wstr);
return FALSE;
- if (SecurityInformation & SACL_SECURITY_INFORMATION)
- if (!DumpSacl(SecurityDescriptor, &wptr, NULL))
+ }
+ if (RequestedInformation & SACL_SECURITY_INFORMATION)
+ if (!DumpSacl(SecurityDescriptor, &wptr, NULL)) {
+ LocalFree (wstr);
return FALSE;
+ }
*wptr = 0;
TRACE("ret: %s, %d\n", wine_dbgstr_w(wstr), len);
/******************************************************************************
* ConvertSecurityDescriptorToStringSecurityDescriptorA [ADVAPI32.@]
- * @implemented
*/
-BOOL WINAPI
-ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR SecurityDescriptor,
- DWORD SDRevision,
- SECURITY_INFORMATION Information,
- LPSTR *OutputString,
- PULONG OutputLen)
+BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD SDRevision, SECURITY_INFORMATION Information, LPSTR *OutputString, PULONG OutputLen)
{
LPWSTR wstr;
ULONG len;
-
if (ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, SDRevision, Information, &wstr, &len))
{
int lenA;
lenA = WideCharToMultiByte(CP_ACP, 0, wstr, len, NULL, 0, NULL, NULL);
- *OutputString = HeapAlloc(GetProcessHeap(), 0, lenA);
+ *OutputString = heap_alloc(lenA);
+#ifdef __REACTOS__
if (*OutputString == NULL)
{
LocalFree(wstr);
*OutputLen = 0;
return FALSE;
}
+#endif
WideCharToMultiByte(CP_ACP, 0, wstr, len, *OutputString, lenA, NULL, NULL);
LocalFree(wstr);
}
}
-/*
- * @implemented
+/******************************************************************************
+ * ConvertStringSidToSidW [ADVAPI32.@]
*/
-BOOL
-WINAPI
-ConvertStringSidToSidW(IN LPCWSTR StringSid,
- OUT PSID* sid)
+BOOL WINAPI ConvertStringSidToSidW(LPCWSTR StringSid, PSID* Sid)
{
- DWORD size;
- DWORD i, cBytes, identAuth, csubauth;
- BOOL ret;
- SID* pisid;
-
- TRACE("%s %p\n", debugstr_w(StringSid), sid);
-
- if (!StringSid)
- {
- SetLastError(ERROR_INVALID_SID);
- return FALSE;
- }
-
- for (i = 0; i < sizeof(SidTable) / sizeof(SidTable[0]) - 1; i++)
- {
- if (wcscmp(StringSid, SidTable[i].key) == 0)
- {
- WELL_KNOWN_SID_TYPE knownSid = (WELL_KNOWN_SID_TYPE)SidTable[i].value;
- size = SECURITY_MAX_SID_SIZE;
- *sid = LocalAlloc(0, size);
- if (!*sid)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
- ret = CreateWellKnownSid(knownSid,
- NULL,
- *sid,
- &size);
- if (!ret)
- {
- SetLastError(ERROR_INVALID_SID);
- LocalFree(*sid);
- }
- return ret;
- }
- }
-
- /* That's probably a string S-R-I-S-S... */
- if (StringSid[0] != 'S' || StringSid[1] != '-')
- {
- SetLastError(ERROR_INVALID_SID);
- return FALSE;
- }
-
- cBytes = ComputeStringSidSize(StringSid);
- pisid = (SID*)LocalAlloc( 0, cBytes );
- if (!pisid)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
- i = 0;
- ret = FALSE;
- csubauth = ((cBytes - GetSidLengthRequired(0)) / sizeof(DWORD));
-
- StringSid += 2; /* Advance to Revision */
- pisid->Revision = atoiW(StringSid);
-
- if (pisid->Revision != SDDL_REVISION)
- {
- TRACE("Revision %d is unknown\n", pisid->Revision);
- goto lend; /* ERROR_INVALID_SID */
- }
- if (csubauth == 0)
- {
- TRACE("SubAuthorityCount is 0\n");
- goto lend; /* ERROR_INVALID_SID */
- }
-
- pisid->SubAuthorityCount = csubauth;
-
- /* Advance to identifier authority */
- while (*StringSid && *StringSid != '-')
- StringSid++;
- if (*StringSid == '-')
- StringSid++;
-
- /* MS' implementation can't handle values greater than 2^32 - 1, so
- * we don't either; assume most significant bytes are always 0
- */
- pisid->IdentifierAuthority.Value[0] = 0;
- pisid->IdentifierAuthority.Value[1] = 0;
- identAuth = atoiW(StringSid);
- pisid->IdentifierAuthority.Value[5] = identAuth & 0xff;
- pisid->IdentifierAuthority.Value[4] = (identAuth & 0xff00) >> 8;
- pisid->IdentifierAuthority.Value[3] = (identAuth & 0xff0000) >> 16;
- pisid->IdentifierAuthority.Value[2] = (identAuth & 0xff000000) >> 24;
-
- /* Advance to first sub authority */
- while (*StringSid && *StringSid != '-')
- StringSid++;
- if (*StringSid == '-')
- StringSid++;
+ BOOL bret = FALSE;
+ DWORD cBytes;
- while (*StringSid)
+ TRACE("%s, %p\n", debugstr_w(StringSid), Sid);
+ if (GetVersion() & 0x80000000)
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ else if (!StringSid || !Sid)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (ParseStringSidToSid(StringSid, NULL, &cBytes))
{
- pisid->SubAuthority[i++] = atoiW(StringSid);
+ PSID pSid = *Sid = LocalAlloc(0, cBytes);
- while (*StringSid && *StringSid != '-')
- StringSid++;
- if (*StringSid == '-')
- StringSid++;
- }
-
- if (i != pisid->SubAuthorityCount)
- goto lend; /* ERROR_INVALID_SID */
-
- *sid = pisid;
- ret = TRUE;
-
-lend:
- if (!ret)
- {
- LocalFree(pisid);
- SetLastError(ERROR_INVALID_SID);
+ bret = ParseStringSidToSid(StringSid, pSid, &cBytes);
+ if (!bret)
+ LocalFree(*Sid);
}
-
- TRACE("returning %s\n", ret ? "TRUE" : "FALSE");
- return ret;
+ return bret;
}
-/*
- * @implemented
+/******************************************************************************
+ * ConvertStringSidToSidA [ADVAPI32.@]
*/
-BOOL
-WINAPI
-ConvertStringSidToSidA(IN LPCSTR StringSid,
- OUT PSID* sid)
+BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
{
- BOOL bRetVal = FALSE;
+ BOOL bret = FALSE;
- TRACE("%s, %p\n", debugstr_a(StringSid), sid);
+ TRACE("%s, %p\n", debugstr_a(StringSid), Sid);
if (GetVersion() & 0x80000000)
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- else if (!StringSid || !sid)
+ else if (!StringSid || !Sid)
SetLastError(ERROR_INVALID_PARAMETER);
else
{
- UINT len = MultiByteToWideChar(CP_ACP, 0, StringSid, -1, NULL, 0);
- LPWSTR wStringSid = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (wStringSid == NULL)
- return FALSE;
- MultiByteToWideChar(CP_ACP, 0, StringSid, - 1, wStringSid, len);
- bRetVal = ConvertStringSidToSidW(wStringSid, sid);
- HeapFree(GetProcessHeap(), 0, wStringSid);
+ WCHAR *wStringSid = SERV_dup(StringSid);
+ bret = ConvertStringSidToSidW(wStringSid, Sid);
+ heap_free(wStringSid);
}
- return bRetVal;
+ return bret;
}
/*
return FALSE;
}
-BOOL
-WINAPI
-CreateProcessWithTokenW(IN HANDLE hToken,
- IN DWORD dwLogonFlags,
- IN LPCWSTR lpApplicationName OPTIONAL,
- IN OUT LPWSTR lpCommandLine OPTIONAL,
- IN DWORD dwCreationFlags,
- IN LPVOID lpEnvironment OPTIONAL,
- IN LPCWSTR lpCurrentDirectory OPTIONAL,
- IN LPSTARTUPINFOW lpStartupInfo,
- OUT LPPROCESS_INFORMATION lpProcessInfo)
+BOOL WINAPI CreateProcessWithTokenW(HANDLE token, DWORD logon_flags, LPCWSTR application_name, LPWSTR command_line,
+ DWORD creation_flags, void *environment, LPCWSTR current_directory, STARTUPINFOW *startup_info,
+ PROCESS_INFORMATION *process_information )
{
- UNIMPLEMENTED;
- return FALSE;
+ FIXME("%p 0x%08x %s %s 0x%08x %p %s %p %p - semi-stub\n", token,
+ logon_flags, debugstr_w(application_name), debugstr_w(command_line),
+ creation_flags, environment, debugstr_w(current_directory),
+ startup_info, process_information);
+
+ /* FIXME: check if handles should be inherited */
+ return CreateProcessW( application_name, command_line, NULL, NULL, FALSE, creation_flags, environment,
+ current_directory, startup_info, process_information );
}
/*
for (i = 0; i < sizeof(WellKnownSids)/sizeof(WellKnownSids[0]); i++)
if (!strncmpW(WellKnownSids[i].wstr, StringSid, 2))
return GetSidLengthRequired(WellKnownSids[i].Sid.SubAuthorityCount);
+
+ for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
+ if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
+ {
+ MAX_SID local;
+ ADVAPI_GetComputerSid(&local);
+ return GetSidLengthRequired(*GetSidSubAuthorityCount(&local) + 1);
+ }
+
}
return GetSidLengthRequired(0);
while (*StringSid == ' ')
StringSid++;
+ if (!*StringSid)
+ goto lend; /* ERROR_INVALID_SID */
+
*cBytes = ComputeStringSidSize(StringSid);
if (!pisid) /* Simply compute the size */
{
- TRACE("only size requested, returning TRUE\n");
+ TRACE("only size requested, returning TRUE with %d\n", *cBytes);
return TRUE;
}
bret = TRUE;
}
+ for (i = 0; i < sizeof(WellKnownRids)/sizeof(WellKnownRids[0]); i++)
+ if (!strncmpW(WellKnownRids[i].wstr, StringSid, 2))
+ {
+ ADVAPI_GetComputerSid(pisid);
+ pisid->SubAuthority[pisid->SubAuthorityCount] = WellKnownRids[i].Rid;
+ pisid->SubAuthorityCount++;
+ bret = TRUE;
+ }
+
if (!bret)
FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
}
return r;
}
-/*
- * @unimplemented
+/******************************************************************************
+ * GetWindowsAccountDomainSid [ADVAPI32.@]
*/
-BOOL
-WINAPI
-GetWindowsAccountDomainSid(IN PSID pSid,
- OUT PSID ppDomainSid,
- IN OUT DWORD* cbSid)
+BOOL WINAPI GetWindowsAccountDomainSid( PSID sid, PSID domain_sid, DWORD *size )
{
- UNIMPLEMENTED;
- return FALSE;
+ SID_IDENTIFIER_AUTHORITY domain_ident = { SECURITY_NT_AUTHORITY };
+ DWORD required_size;
+ int i;
+
+ FIXME( "(%p %p %p): semi-stub\n", sid, domain_sid, size );
+
+ if (!sid || !IsValidSid( sid ))
+ {
+ SetLastError( ERROR_INVALID_SID );
+ return FALSE;
+ }
+
+ if (!size)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+
+ if (*GetSidSubAuthorityCount( sid ) < 4)
+ {
+ SetLastError( ERROR_INVALID_SID );
+ return FALSE;
+ }
+
+ required_size = GetSidLengthRequired( 4 );
+ if (*size < required_size || !domain_sid)
+ {
+ *size = required_size;
+ SetLastError( domain_sid ? ERROR_INSUFFICIENT_BUFFER :
+ ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+
+ InitializeSid( domain_sid, &domain_ident, 4 );
+ for (i = 0; i < 4; i++)
+ *GetSidSubAuthority( domain_sid, i ) = *GetSidSubAuthority( sid, i );
+
+ *size = required_size;
+ return TRUE;
}
/*