protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } UMMailbox ummailbox = UMMailbox.FromDataObject(aduser); if (ummailbox.UMDialPlan != null) { UMDialPlan dialPlan = ummailbox.GetDialPlan(); if (dialPlan != null && (dialPlan.URIType == UMUriType.E164 || dialPlan.URIType == UMUriType.SipName)) { ummailbox.SIPResourceIdentifier = UMMailbox.GetPrimaryExtension(ummailbox.EmailAddresses, ProxyAddressPrefix.UM); } if (dialPlan != null) { ummailbox.PhoneNumber = ummailbox.GetEUMPhoneNumber(dialPlan); } ummailbox.AccessTelephoneNumbers = dialPlan.AccessTelephoneNumbers; ummailbox.CallAnsweringRulesExtensions = new MultiValuedProperty <string>(Utils.GetExtensionsInDialPlanValidForPAA(dialPlan, aduser)); } return(ummailbox); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } return(new LinkedUser(aduser)); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser user = (ADUser)dataObject; SharedConfiguration sharedConfig = null; if (SharedConfiguration.IsDehydratedConfiguration(user.OrganizationId) || (SharedConfiguration.GetSharedConfigurationState(user.OrganizationId) & SharedTenantConfigurationState.Static) != SharedTenantConfigurationState.UnSupported) { sharedConfig = base.ProvisioningCache.TryAddAndGetOrganizationData <SharedConfiguration>(CannedProvisioningCacheKeys.MailboxSharedConfigCacheKey, user.OrganizationId, () => SharedConfiguration.GetSharedConfiguration(user.OrganizationId)); } if (null != user.MasterAccountSid) { user.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(user.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); user.ResetChangeTracking(); } Mailbox mailbox = new Mailbox(user); mailbox.propertyBag.SetField(MailboxSchema.Database, ADObjectIdResolutionHelper.ResolveDN(mailbox.Database)); if (sharedConfig != null) { mailbox.SharedConfiguration = sharedConfig.SharedConfigId.ConfigurationUnit; if (mailbox.RoleAssignmentPolicy == null) { mailbox.RoleAssignmentPolicy = base.ProvisioningCache.TryAddAndGetOrganizationData <ADObjectId>(CannedProvisioningCacheKeys.MailboxRoleAssignmentPolicyCacheKey, user.OrganizationId, () => sharedConfig.GetSharedRoleAssignmentPolicy()); } } else if (mailbox.RoleAssignmentPolicy == null && !mailbox.ExchangeVersion.IsOlderThan(MailboxSchema.RoleAssignmentPolicy.VersionAdded)) { ADObjectId defaultRoleAssignmentPolicy = RBACHelper.GetDefaultRoleAssignmentPolicy(user.OrganizationId); if (defaultRoleAssignmentPolicy != null) { mailbox.RoleAssignmentPolicy = defaultRoleAssignmentPolicy; } } if (mailbox.SharingPolicy == null && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.SharingPolicy)) { mailbox.SharingPolicy = base.GetDefaultSharingPolicyId(user, sharedConfig); } if (mailbox.RetentionPolicy == null && mailbox.ShouldUseDefaultRetentionPolicy && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetentionPolicy)) { mailbox.RetentionPolicy = base.GetDefaultRetentionPolicyId(user, sharedConfig); } if (mailbox.Database != null && mailbox.UseDatabaseRetentionDefaults) { this.SetDefaultRetentionValues(mailbox); } mailbox.AdminDisplayVersion = Microsoft.Exchange.Data.Directory.SystemConfiguration.Server.GetServerVersion(mailbox.ServerName); return(mailbox); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { ADGroup adgroup = (ADGroup)dataObject; if (null != adgroup.ForeignGroupSid) { adgroup.LinkedGroup = SecurityPrincipalIdParameter.GetFriendlyUserName(adgroup.ForeignGroupSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); adgroup.ResetChangeTracking(); } RoleGroup roleGroup = RoleGroupCommon.PopulateRoleAssignmentsAndConvert(adgroup, this.ConfigurationSession); roleGroup.PopulateCapabilitiesProperty(); return(roleGroup); }
protected override void WriteResult(ADObject result) { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); ADUser aduser = (ADUser)result; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } base.WriteResult(new LinkedUser(aduser)); TaskLogger.LogExit(); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } MailboxPlan mailboxPlan = new MailboxPlan(aduser); mailboxPlan.Database = ADObjectIdResolutionHelper.ResolveDN(mailboxPlan.Database); return(mailboxPlan); }
internal static string GetFriendlyNameOfSecurityIdentifier(SecurityIdentifier sid, IRecipientSession session, Task.TaskErrorLoggingDelegate errorLogger, Task.TaskVerboseLoggingDelegate verboseLogger) { if (!RecipientPermissionTaskHelper.sidToName.ContainsKey(sid)) { ADRecipient adrecipient = (ADRecipient)SecurityPrincipalIdParameter.GetSecurityPrincipal(session, new SecurityPrincipalIdParameter(sid), errorLogger, verboseLogger); if (adrecipient != null) { if (adrecipient.Id != null) { RecipientPermissionTaskHelper.sidToName[sid] = adrecipient.Id.ToString(); } else { RecipientPermissionTaskHelper.sidToName[sid] = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, verboseLogger); } } } return(RecipientPermissionTaskHelper.sidToName[sid]); }
protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject) { if (dataObject == null) { return(null); } ADUser aduser = (ADUser)dataObject; if (null != aduser.MasterAccountSid) { aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); aduser.ResetChangeTracking(); } CASMailbox casmailbox = CASMailbox.FromDataObject(aduser); if ((this.GetPopProtocolLog || this.GetImapProtocolLog || this.ActiveSyncDebugLogging) && CmdletProxy.TryToProxyOutputObject(casmailbox, base.CurrentTaskContext, aduser, this.Identity == null, this.ConfirmationMessage, CmdletProxy.AppendIdentityToProxyCmdlet(aduser))) { return(casmailbox); } if (casmailbox.ActiveSyncMailboxPolicy == null && !casmailbox.ExchangeVersion.IsOlderThan(CASMailboxSchema.ActiveSyncMailboxPolicy.VersionAdded)) { ADObjectId defaultPolicyId = base.GetDefaultPolicyId(aduser); if (defaultPolicyId != null) { casmailbox.SetActiveSyncMailboxPolicyLocally(defaultPolicyId); casmailbox.ActiveSyncMailboxPolicyIsDefaulted = true; } } if (this.GetPopProtocolLog || this.GetImapProtocolLog) { this.GetProtocolLogs(aduser); } if (this.ProtocolSettings) { this.PopulateProtocolSettings(casmailbox); } if (this.ActiveSyncDebugLogging) { casmailbox.ActiveSyncDebugLogging = this.GetActiveSyncLoggingEnabled(aduser); } return(casmailbox); }
private string GetDisplayNameFromSid(string userSid) { if (this.resolvedUserNameList.ContainsKey(userSid)) { return(this.resolvedUserNameList[userSid]); } SecurityIdentifier securityIdentifier = new SecurityIdentifier(userSid); ADRecipient adrecipient = this.recipientSessionInternal.FindBySid(securityIdentifier); string text; if (adrecipient != null) { text = MailboxAuditLogSearchWorker.ResolveMailboxOwnerName(adrecipient); } else { text = SecurityPrincipalIdParameter.GetFriendlyUserName(securityIdentifier, null); } this.resolvedUserNameList[userSid] = text; return(text); }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(this.DataObject.Identity, base.DataSession, typeof(RoleGroup))); ADGroup adgroup = null; try { adgroup = (ADGroup)base.DataSession.Read <ADGroup>(this.DataObject.Identity); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (adgroup == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(this.DataObject.Identity), typeof(RoleGroup).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, this.DataObject.Identity); } Result <ExchangeRoleAssignment>[] array = null; if (this.roleAssignments != null) { array = new Result <ExchangeRoleAssignment> [this.roleAssignments.Count]; for (int i = 0; i < this.roleAssignments.Count; i++) { array[i] = new Result <ExchangeRoleAssignment>(this.roleAssignments[i], null); } } if (null != adgroup.ForeignGroupSid) { adgroup.LinkedGroup = SecurityPrincipalIdParameter.GetFriendlyUserName(adgroup.ForeignGroupSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); adgroup.ResetChangeTracking(); } RoleGroup result = new RoleGroup(adgroup, array); base.WriteResult(result); 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(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (base.IsInherited) { return; } if ("Owner" == base.ParameterSetName) { IConfigurationSession writableSession = base.GetWritableSession(this.DataObject.Id); ActiveDirectorySecurity activeDirectorySecurity = PermissionTaskHelper.ReadAdSecurityDescriptor(this.DataObject, writableSession, new Task.TaskErrorLoggingDelegate(base.WriteError)); SecurityIdentifier sid = this.owner; activeDirectorySecurity.SetOwner(sid); RawSecurityDescriptor sd = new RawSecurityDescriptor(activeDirectorySecurity.GetSecurityDescriptorBinaryForm(), 0); writableSession.SaveSecurityDescriptor(this.DataObject.Id, sd, true); string friendlyUserName = SecurityPrincipalIdParameter.GetFriendlyUserName(sid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); base.WriteObject(new OwnerPresentationObject(this.DataObject.Id, friendlyUserName)); } else { base.InternalProcessRecord(); } TaskLogger.LogExit(); }
private void CompleteDataObject(ExtendedSecurityPrincipal dataObject) { dataObject.UserFriendlyName = SecurityPrincipalIdParameter.GetFriendlyUserName(dataObject.SID, null); }
internal static bool ApplyAcesOnAcl(Task.TaskVerboseLoggingDelegate verboseLogger, Task.TaskWarningLoggingDelegate warningLogger, Task.ErrorLoggerDelegate errorLogger, string objectIdentityString, ActiveDirectorySecurity acl, bool remove, params ActiveDirectoryAccessRule[] aces) { bool result = false; if (!acl.AreAccessRulesCanonical) { LocalizedString message = Strings.InfoAclNotCanonical(objectIdentityString); if (errorLogger != null) { errorLogger(new TaskInvalidOperationException(message), ExchangeErrorCategory.ServerOperation, null); } else if (warningLogger != null) { warningLogger(message); } else if (verboseLogger != null) { verboseLogger(message); } return(false); } int i = 0; while (i < aces.Length) { ActiveDirectoryAccessRule activeDirectoryAccessRule = aces[i]; bool flag = false; ActiveDirectoryAccessRule activeDirectoryAccessRule2 = DirectoryCommon.FindAce(activeDirectoryAccessRule, acl, true, remove); if (null != activeDirectoryAccessRule2 != remove && (activeDirectoryAccessRule2 == null || !activeDirectoryAccessRule2.IsInherited)) { goto IL_13D; } if (!remove || !activeDirectoryAccessRule2.IsInherited) { if (verboseLogger != null) { if (remove) { verboseLogger(Strings.InfoRemovingAce(objectIdentityString, DirectoryCommon.AceToString(activeDirectoryAccessRule))); } else { verboseLogger(Strings.InfoAddingAce(objectIdentityString, DirectoryCommon.AceToString(activeDirectoryAccessRule))); } } if (remove) { DirectoryCommon.RemoveAccessRule(acl, activeDirectoryAccessRule); } else { acl.AddAccessRule(activeDirectoryAccessRule); } flag = (result = true); goto IL_13D; } LocalizedString message2 = Strings.ErrorWillNotPerformOnInheritedAce(activeDirectoryAccessRule2.ActiveDirectoryRights.ToString(), activeDirectoryAccessRule2.AccessControlType.ToString(), objectIdentityString); if (errorLogger != null) { errorLogger(new TaskInvalidOperationException(message2), ExchangeErrorCategory.ServerOperation, null); } else if (warningLogger != null) { warningLogger(message2); } else if (verboseLogger != null) { verboseLogger(message2); } IL_1DB: i++; continue; IL_13D: if ((flag && DirectoryCommon.FindAce(activeDirectoryAccessRule, acl, false, remove) == null == remove) || (verboseLogger == null && warningLogger == null && errorLogger == null)) { goto IL_1DB; } LocalizedString message3; if (remove) { if (activeDirectoryAccessRule.ObjectFlags == ObjectAceFlags.ObjectAceTypePresent) { string attr = string.Format("{0} (ObjectType: {1})", activeDirectoryAccessRule.ActiveDirectoryRights, activeDirectoryAccessRule.ObjectType); message3 = Strings.InfoAttributeAceNotPresent(objectIdentityString, attr); } else { message3 = Strings.InfoAceNotPresent(objectIdentityString, SecurityPrincipalIdParameter.GetFriendlyUserName(activeDirectoryAccessRule.IdentityReference, verboseLogger)); } } else { message3 = Strings.InfoAceAlreadyPresent(objectIdentityString, SecurityPrincipalIdParameter.GetFriendlyUserName(activeDirectoryAccessRule.IdentityReference, verboseLogger)); } if (warningLogger != null) { warningLogger(message3); goto IL_1DB; } if (verboseLogger != null) { verboseLogger(message3); goto IL_1DB; } goto IL_1DB; } return(result); }