protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(); this.HasObjectMatchingIdentity = true; ADUser aduser = (ADUser)dataObject; if (aduser.Database == null || aduser.ExchangeGuid == Guid.Empty) { base.Validate(aduser); } else { ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadMailboxSecurityDescriptor((ADUser)dataObject, PermissionTaskHelper.GetReadOnlySession(base.DomainController), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); if (!this.Owner.IsPresent) { AuthorizationRuleCollection accessRules = activeDirectorySecurity.GetAccessRules(true, true, typeof(SecurityIdentifier)); int num = 0; while (accessRules.Count > num) { ActiveDirectoryAccessRule activeDirectoryAccessRule = (ActiveDirectoryAccessRule)accessRules[num]; if (this.SecurityPrincipal == null || this.SecurityPrincipal.Sid == activeDirectoryAccessRule.IdentityReference || this.SecurityPrincipal.SidHistory.Contains(activeDirectoryAccessRule.IdentityReference as SecurityIdentifier)) { MailboxAcePresentationObject mailboxAcePresentationObject = new MailboxAcePresentationObject(activeDirectoryAccessRule, ((ADRawEntry)dataObject).Id); if (Globals.IsDatacenter && base.TenantGlobalCatalogSession != null) { SecurityIdentifier securityIdentifier = (SecurityIdentifier)activeDirectoryAccessRule.IdentityReference; ADRecipient adrecipient = null; try { adrecipient = base.TenantGlobalCatalogSession.FindBySid(securityIdentifier); } catch { } if (adrecipient != null) { string friendlyName = (!string.IsNullOrEmpty(adrecipient.DisplayName)) ? adrecipient.DisplayName : adrecipient.Name; mailboxAcePresentationObject.User = new SecurityPrincipalIdParameter(securityIdentifier, friendlyName); } } mailboxAcePresentationObject.ResetChangeTracking(true); base.WriteResult(mailboxAcePresentationObject); } num++; } } else { IdentityReference owner = activeDirectorySecurity.GetOwner(typeof(NTAccount)); OwnerPresentationObject dataObject2 = new OwnerPresentationObject(((ADUser)dataObject).Id, owner.ToString()); base.WriteResult(dataObject2); } } TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (base.IsInherited) { return; } if ("Owner" == base.ParameterSetName) { ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadMailboxSecurityDescriptor(this.DataObject, PermissionTaskHelper.GetReadOnlySession(base.DomainController), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); SecurityIdentifier sid = this.owner; activeDirectorySecurity.SetOwner(sid); new RawSecurityDescriptor(activeDirectorySecurity.GetSecurityDescriptorBinaryForm(), 0); PermissionTaskHelper.SaveMailboxSecurityDescriptor(this.DataObject, activeDirectorySecurity, base.DataSession, ref this.storeSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); string friendlyUserName = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); base.WriteObject(new OwnerPresentationObject(this.DataObject.Id, friendlyUserName)); } else { base.InternalProcessRecord(); } TaskLogger.LogExit(); }