public void Delete(IConfigurable instance) { if (instance == null) { throw new ArgumentNullException("instance"); } if (this.configurationSession.ReadOnly) { throw new InvalidOperationException("read only"); } if (this.serviceInstanceName == null) { throw new InvalidOperationException("Delete can be performed only for specific service instance."); } FullSyncObjectRequest fullSyncObjectRequest = instance as FullSyncObjectRequest; if (fullSyncObjectRequest == null) { throw new NotSupportedException(instance.GetType().FullName); } this.RefreshRidMasterInformation(); MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName); MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests; if (msoForwardSyncObjectFullSyncRequests.Contains(fullSyncObjectRequest)) { msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest); this.configurationSession.Save(msoMainStreamCookieContainer); return; } throw new ADNoSuchObjectException(DirectoryStrings.ExceptionADOperationFailedNoSuchObject(this.configurationSession.DomainController, fullSyncObjectRequest.ToString())); }
public void Save(IConfigurable instance) { if (instance == null) { throw new ArgumentNullException("instance"); } if (this.configurationSession.ReadOnly) { throw new InvalidOperationException("read only"); } if (this.serviceInstanceName == null) { throw new InvalidOperationException("Save can be performed only for specific service instance."); } FullSyncObjectRequest request = instance as FullSyncObjectRequest; if (request == null) { throw new NotSupportedException(instance.GetType().FullName); } this.RefreshRidMasterInformation(); MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName); MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests; FullSyncObjectRequest fullSyncObjectRequest = msoForwardSyncObjectFullSyncRequests.Find((FullSyncObjectRequest r) => request.Identity.Equals(r.Identity) && request.ServiceInstanceId == r.ServiceInstanceId); if (fullSyncObjectRequest != null) { if (request.ObjectState == ObjectState.New) { throw new ADObjectAlreadyExistsException(DirectoryStrings.ExceptionADOperationFailedAlreadyExist(this.configurationSession.DomainController, request.ToString())); } if (request.ObjectState == ObjectState.Changed) { msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest); } } else { IEnumerable <FullSyncObjectRequest> source = from r in msoForwardSyncObjectFullSyncRequests where request.ServiceInstanceId == r.ServiceInstanceId select r; int maxObjectFullSyncRequestsPerServiceInstance = ProvisioningTasksConfigImpl.MaxObjectFullSyncRequestsPerServiceInstance; if (source.Count <FullSyncObjectRequest>() >= maxObjectFullSyncRequestsPerServiceInstance) { throw new DataSourceOperationException(Strings.OperationExceedsPerServiceInstanceFullSyncObjectRequestLimit(maxObjectFullSyncRequestsPerServiceInstance, request.ServiceInstanceId)); } } msoForwardSyncObjectFullSyncRequests.Add(request); this.configurationSession.Save(msoMainStreamCookieContainer); }