-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathOrganizationUserOrganizationDetailsViewQuery.cs
More file actions
86 lines (84 loc) · 4.83 KB
/
OrganizationUserOrganizationDetailsViewQuery.cs
File metadata and controls
86 lines (84 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class OrganizationUserOrganizationDetailsViewQuery : IQuery<OrganizationUserOrganizationDetails>
{
public IQueryable<OrganizationUserOrganizationDetails> Run(DatabaseContext dbContext)
{
var query = from ou in dbContext.OrganizationUsers
join o in dbContext.Organizations on ou.OrganizationId equals o.Id
join su in dbContext.SsoUsers on new { ou.UserId, OrganizationId = (Guid?)ou.OrganizationId } equals new { UserId = (Guid?)su.UserId, su.OrganizationId } into su_g
from su in su_g.DefaultIfEmpty()
join po in dbContext.ProviderOrganizations on o.Id equals po.OrganizationId into po_g
from po in po_g.DefaultIfEmpty()
join p in dbContext.Providers on po.ProviderId equals p.Id into p_g
from p in p_g.DefaultIfEmpty()
join ss in dbContext.SsoConfigs on ou.OrganizationId equals ss.OrganizationId into ss_g
from ss in ss_g.DefaultIfEmpty()
join os in dbContext.OrganizationSponsorships on ou.Id equals os.SponsoringOrganizationUserId into os_g
from os in os_g.DefaultIfEmpty()
select new OrganizationUserOrganizationDetails
{
UserId = ou.UserId,
OrganizationId = ou.OrganizationId,
OrganizationUserId = ou.Id,
Name = o.Name,
Enabled = o.Enabled,
PlanType = o.PlanType,
UsePolicies = o.UsePolicies,
UseSso = o.UseSso,
UseKeyConnector = o.UseKeyConnector,
UseScim = o.UseScim,
UseGroups = o.UseGroups,
UseDirectory = o.UseDirectory,
UseEvents = o.UseEvents,
UseTotp = o.UseTotp,
Use2fa = o.Use2fa,
UseApi = o.UseApi,
UseResetPassword = o.UseResetPassword,
UseSecretsManager = o.UseSecretsManager,
SelfHost = o.SelfHost,
UsersGetPremium = o.UsersGetPremium,
UseCustomPermissions = o.UseCustomPermissions,
Seats = o.Seats,
MaxCollections = o.MaxCollections,
MaxStorageGb = o.MaxStorageGb,
Identifier = o.Identifier,
Key = ou.Key,
ResetPasswordKey = ou.ResetPasswordKey,
PublicKey = o.PublicKey,
PrivateKey = o.PrivateKey,
Status = ou.Status,
Type = ou.Type,
SsoExternalId = su.ExternalId,
Permissions = ou.Permissions,
ProviderId = p.Id,
ProviderName = p.Name,
ProviderType = p.Type,
SsoEnabled = ss.Enabled,
SsoConfig = ss.Data,
FamilySponsorshipFriendlyName = os.FriendlyName,
FamilySponsorshipLastSyncDate = os.LastSyncDate,
FamilySponsorshipToDelete = os.ToDelete,
FamilySponsorshipValidUntil = os.ValidUntil,
AccessSecretsManager = ou.AccessSecretsManager,
UsePasswordManager = o.UsePasswordManager,
SmSeats = o.SmSeats,
SmServiceAccounts = o.SmServiceAccounts,
LimitCollectionCreation = o.LimitCollectionCreation,
LimitCollectionDeletion = o.LimitCollectionDeletion,
AllowAdminAccessToAllCollectionItems = o.AllowAdminAccessToAllCollectionItems,
UseRiskInsights = o.UseRiskInsights,
UseAdminSponsoredFamilies = o.UseAdminSponsoredFamilies,
LimitItemDeletion = o.LimitItemDeletion,
IsAdminInitiated = os.IsAdminInitiated,
UseOrganizationDomains = o.UseOrganizationDomains,
UseAutomaticUserConfirmation = o.UseAutomaticUserConfirmation,
UseDisableSMAdsForUsers = o.UseDisableSmAdsForUsers,
UsePhishingBlocker = o.UsePhishingBlocker,
UseMyItems = o.UseMyItems,
UseInviteLinks = o.UseInviteLinks,
RevocationReason = ou.RevocationReason
};
return query;
}
}