public UnifiedGroupsTask(ADUser accessingUser, IRecipientSession adSession, Guid activityId) { this.AccessingUser = accessingUser; this.ADSession = adSession; this.AADClient = AADClientFactory.Create(accessingUser); this.ActivityId = activityId; }
private static IAadClient CreateAadClient(OrganizationId organizationId, GraphProxyVersions graphProxyVersion) { if (TestHooks.GraphApi_GetAadClient != null) { return(TestHooks.GraphApi_GetAadClient(organizationId)); } return(AADClientFactory.Create(organizationId, graphProxyVersion)); }
private IAadClient GetAADClient(MailboxAssociation association) { if (AADClientTestHooks.GraphApi_GetAadClient != null) { return(AADClientTestHooks.GraphApi_GetAadClient()); } ADUser user = association.User.FindAdUser(); return(AADClientFactory.Create(user)); }
private AADClient CreateAADClient(ADUser user) { AADClient aadclient = AADClientFactory.Create(user); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); } return(aadclient); }
protected override void InternalProcessRecord() { AADClient aadclient = AADClientFactory.Create(base.OrganizationId, GraphProxyVersions.Version14); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); return; } if (this.Identity != null) { Group group; try { group = aadclient.GetGroup(this.Identity.Value.ToString(), true); } catch (AADException ex) { base.WriteVerbose("GetGroup failed with exception: {0}", new object[] { ex }); base.WriteError(new TaskException(Strings.ErrorUnableToGetUnifiedGroup), base.GetErrorCategory(ex), null); return; } aadclient.Service.LoadProperty(group, "createdOnBehalfOf"); aadclient.Service.LoadProperty(group, "members"); aadclient.Service.LoadProperty(group, "owners"); this.WriteAADGroupObject(group); return; } try { foreach (Group group2 in aadclient.GetGroups()) { this.WriteAADGroupObject(group2); } } catch (AADException ex2) { base.WriteVerbose("GetGroups failed with exception: {0}", new object[] { ex2 }); base.WriteError(new TaskException(Strings.ErrorUnableToGetUnifiedGroup), base.GetErrorCategory(ex2), null); } }
private void UpdateFromGroupMailbox() { ADUser aduser = this.recipientSession.FindADUserByExternalDirectoryObjectId(this.Identity.ToString()); ADUser ownerFromAAD = this.GetOwnerFromAAD(aduser, this.recipientSession); string[] members = base.GetMembers(aduser, this.recipientSession, "Set-UnifiedGroup"); string[] owners = base.GetOwners(aduser, null, this.recipientSession); string description = (aduser.Description != null && aduser.Description.Count > 0) ? aduser.Description[0] : string.Empty; string[] exchangeResources = this.GetExchangeResources(aduser); AADClient aadclient = AADClientFactory.Create(ownerFromAAD); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); } this.UpdateGroup(aduser.DisplayName, description, exchangeResources, aduser.ExternalDirectoryObjectId, aadclient); base.AddOwnersInAAD(owners, aadclient, aduser.ExternalDirectoryObjectId); base.AddMembersInAAD(members, aadclient, aduser.ExternalDirectoryObjectId); }
protected override void InternalProcessRecord() { if (base.Fields.IsModified("SyncGroupMailbox") && this.SyncGroupMailbox) { this.UpdateFromGroupMailbox(); return; } ADUser groupMailbox = this.recipientSession.FindADUserByExternalDirectoryObjectId(this.Identity.ToString()); ADUser ownerFromAAD = this.GetOwnerFromAAD(groupMailbox, this.recipientSession); string[] exchangeResources = this.GetExchangeResources(groupMailbox); AADClient aadclient = AADClientFactory.Create(ownerFromAAD); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); } this.UpdateGroup(this.DisplayName, this.Description, exchangeResources, this.Identity.ToString(), aadclient); base.AddOwnersInAAD(this.addOwners, aadclient, this.Identity.ToString()); base.RemoveOwnersInAAD(this.removeOwners, aadclient, this.Identity.ToString()); base.AddMembersInAAD(this.addMembers, aadclient, this.Identity.ToString()); base.RemoveMembersInAAD(this.removeMembers, aadclient, this.Identity.ToString()); }
protected override void InternalProcessRecord() { AADClient aadclient = AADClientFactory.Create(base.OrganizationId, GraphProxyVersions.Version14); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); } try { base.WriteVerbose("Calling DeleteGroup", new object[0]); aadclient.DeleteGroup(this.Identity.ToString()); base.WriteVerbose("DeleteGroup succeeded", new object[0]); } catch (AADException ex) { base.WriteVerbose("DeleteGroup failed with exception: {0}", new object[] { ex }); base.WriteError(new TaskException(Strings.ErrorUnableToRemove(this.Identity.ToString())), base.GetErrorCategory(ex), null); } }
// Token: 0x06001B78 RID: 7032 RVA: 0x000691F4 File Offset: 0x000673F4 private bool IsModernGroupUnique() { bool result = false; Stopwatch stopwatch = Stopwatch.StartNew(); AADClient aadclient = AADClientFactory.Create(base.CallContext.ADRecipientSessionContext.OrganizationId, GraphProxyVersions.Version14); if (aadclient == null) { return(true); } try { result = aadclient.IsAliasUnique(this.request.Alias); this.LogElapsedTime(CreateModernGroupCommandMetadata.AADAliasQueryTime, new TimeSpan?(stopwatch.Elapsed)); } catch (AADException ex) { this.LogElapsedTime(CreateModernGroupCommandMetadata.AADAliasQueryTime, new TimeSpan?(stopwatch.Elapsed)); ExTraceGlobals.ModernGroupsTracer.TraceError <SmtpAddress, AADException>((long)this.GetHashCode(), "CreateUnifiedGroupCommand: User: {0}. Exception: {1}. AADClient.IsAliasUnique failed", base.CallContext.AccessingPrincipal.MailboxInfo.PrimarySmtpAddress, ex); base.CallContext.ProtocolLog.Set(CreateModernGroupCommandMetadata.Exception, ex); } return(result); }
private ADUser GetOwnerFromAAD(ADUser groupMailbox, IRecipientSession recipientSession) { Group group = null; AADClient aadclient = AADClientFactory.Create(base.OrganizationId, GraphProxyVersions.Version14); if (aadclient == null) { base.WriteError(new TaskException(Strings.ErrorUnableToSessionWithAAD), ExchangeErrorCategory.Client, null); } try { group = aadclient.GetGroup(groupMailbox.ExternalDirectoryObjectId, true); aadclient.Service.LoadProperty(group, "owners"); } catch (AADException ex) { base.WriteVerbose("Failed to get group owner from AAD with exception: {0}", new object[] { ex }); base.WriteError(new TaskException(Strings.ErrorUnableToGetGroupOwners), base.GetErrorCategory(ex), null); } if (group.owners != null) { foreach (DirectoryObject directoryObject in group.owners) { ADUser aduser = recipientSession.FindADUserByExternalDirectoryObjectId(directoryObject.objectId); if (aduser != null) { return(aduser); } } } base.WriteError(new TaskException(Strings.ErrorUnableToGetGroupOwners), ExchangeErrorCategory.Client, null); return(null); }
public bool Publish(int?publishedVersion) { if (!GroupMailboxExchangeResourcesPublisher.IsPublishedVersionOutdated(publishedVersion)) { return(true); } MailboxUrls mailboxUrls = new MailboxUrls(ExchangePrincipal.FromADUser(this.groupADUser, null), true); AADClient aadclient = AADClientFactory.Create(this.groupADUser.OrganizationId, GraphProxyVersions.Version14); if (aadclient == null) { string value = string.Format("AADClient was null for organization {0} and group {1}", this.groupADUser.OrganizationId, this.groupADUser.ExternalDirectoryObjectId); throw new LocalizedException(new LocalizedString(value)); } if (publishedVersion == null) { Group group = aadclient.GetGroup(this.groupADUser.ExternalDirectoryObjectId, false); if (group == null) { FederatedDirectoryLogger.AppendToLog(new SchemaBasedLogEvent <FederatedDirectoryLogSchema.TraceTag> { { FederatedDirectoryLogSchema.TraceTag.TaskName, "PublishResourcesToAAD" }, { FederatedDirectoryLogSchema.TraceTag.ActivityId, this.activityId }, { FederatedDirectoryLogSchema.TraceTag.CurrentAction, "GetGroupFromAAD" }, { FederatedDirectoryLogSchema.TraceTag.Message, string.Format("Unable to find group in AAD. ExternalId={0}", this.groupADUser.ExternalDirectoryObjectId) } }); return(false); } string[] array; if (group.exchangeResources == null) { array = new string[0]; } else { array = (from s in @group.exchangeResources select s.ToLower()).ToArray <string>(); } string[] array2 = array; string[] array3 = (from s in mailboxUrls.ToExchangeResources() select s.ToLower()).ToArray <string>(); if (array2.Length == array3.Length && array2.Except(array3).Count <string>() == 0) { return(true); } } string[] exchangeResources = mailboxUrls.ToExchangeResources(); aadclient.UpdateGroup(this.groupADUser.ExternalDirectoryObjectId, null, exchangeResources, null, null); this.TryNotifySharePointForExchangeResources(mailboxUrls); return(true); }