1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-28 23:04:50 -05:00
bitwarden/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql
2017-05-04 07:17:01 -04:00

19 lines
541 B
Transact-SQL

CREATE VIEW [dbo].[CollectionUserUserDetailsView]
AS
SELECT
OU.[Id] AS [OrganizationUserId],
OU.[OrganizationId],
OU.[AccessAll],
CU.[Id],
CU.[CollectionId],
U.[Name],
ISNULL(U.[Email], OU.[Email]) Email,
OU.[Status],
OU.[Type],
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = OU.[Id]
LEFT JOIN
[dbo].[User] U ON U.[Id] = OU.[UserId]