Ejemplo n.º 1
0
        private void ProcessGetContext()
        {
            TenantSyncSummary tenantSyncSummary = new TenantSyncSummary();
            List <IEnumerable <TenantSyncBatchResults> > list = tenantSyncSummary.Samples as List <IEnumerable <TenantSyncBatchResults> >;

            this.FindTheRightCookie();
            ExProgressRecord exProgressRecord  = new ExProgressRecord(1, new LocalizedString("Tenant Sync"), new LocalizedString("Sync Call"));
            ExProgressRecord exProgressRecord2 = new ExProgressRecord(2, new LocalizedString("Sync Call"), new LocalizedString("GetContext"));

            exProgressRecord2.ParentActivityId = exProgressRecord.ActivityId;
            for (int i = 0; i < this.SampleCountForStatistics; i++)
            {
                exProgressRecord.CurrentOperation = Strings.GetMsoDiagnosticsProgressIteration(i + 1, this.SampleCountForStatistics);
                exProgressRecord.PercentComplete  = i * 100 / this.SampleCountForStatistics;
                exProgressRecord.RecordType       = ProgressRecordType.Processing;
                base.WriteProgress(exProgressRecord);
                byte[] lastCookie    = this.Cookie;
                byte[] lastPageToken = this.PageToken;
                string contextId     = this.ExternalDirectoryOrganizationId;
                List <TenantSyncBatchResults> list2 = new List <TenantSyncBatchResults>();
                list.Add(list2);
                for (int j = 0; j < this.MaxNumberOfBatches; j++)
                {
                    exProgressRecord2.CurrentOperation = Strings.GetMsoDiagnosticsProgressBatch(j + 1, this.MaxNumberOfBatches);
                    exProgressRecord2.PercentComplete  = j * 100 / this.MaxNumberOfBatches;
                    exProgressRecord2.RecordType       = ProgressRecordType.Processing;
                    base.WriteProgress(exProgressRecord2);
                    ExDateTime               now              = ExDateTime.Now;
                    GetContextResponse       context          = this.MsoSyncService.SyncProxy.GetContext(new GetContextRequest(lastCookie, contextId, lastPageToken));
                    TimeSpan                 responseTime     = ExDateTime.Now - now;
                    DirectoryObjectsAndLinks getContextResult = context.GetContextResult;
                    if (getContextResult != null)
                    {
                        TenantSyncBatchResults tenantSyncBatchResults = new TenantSyncBatchResults(getContextResult);
                        tenantSyncBatchResults.Stats.ResponseTime = responseTime;
                        tenantSyncBatchResults.RawResponse        = this.MsoSyncService.RawResponse;
                        tenantSyncBatchResults.LastPageToken      = lastPageToken;
                        tenantSyncBatchResults.CalculateStats();
                        list2.Add(tenantSyncBatchResults);
                        contextId     = null;
                        lastCookie    = null;
                        lastPageToken = getContextResult.NextPageToken;
                    }
                    if (getContextResult == null || !getContextResult.More)
                    {
                        break;
                    }
                }
                if (list2.Last <TenantSyncBatchResults>().More)
                {
                    this.WriteWarning(Strings.GetMsoDiagnosticsMoreDataIsAvailable);
                }
                exProgressRecord2.RecordType = ProgressRecordType.Completed;
                base.WriteProgress(exProgressRecord2);
            }
            exProgressRecord.RecordType = ProgressRecordType.Completed;
            base.WriteProgress(exProgressRecord);
            tenantSyncSummary.CalculateStats();
            base.WriteObject(tenantSyncSummary);
        }
Ejemplo n.º 2
0
        private void ProcessMsoRawObject(SyncObjectId syncObjectId, string serviceInstanceId)
        {
            if (this.service == null)
            {
                this.service = new MsoSyncService();
            }
            bool?allLinksCollected;
            DirectoryObjectsAndLinks msoRawObject = this.service.GetMsoRawObject(syncObjectId, serviceInstanceId, this.IncludeBackLinks.IsPresent, this.IncludeForwardLinks.IsPresent, base.Fields.IsModified("LinksResultSize") ? this.LinksResultSize : 1000, out allLinksCollected);

            if (msoRawObject.Objects.Length != 0)
            {
                MsoRawObject msoRawObject2 = new MsoRawObject(syncObjectId, serviceInstanceId, msoRawObject, allLinksCollected, this.PopulateRawObject.IsPresent);
                msoRawObject2.PopulateSyncObjectData();
                base.WriteObject(msoRawObject2);
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (msoRawObject.Errors.Length != 0)
            {
                foreach (DirectoryObjectError directoryObjectError in msoRawObject.Errors)
                {
                    stringBuilder.Append(directoryObjectError.ErrorCode);
                    stringBuilder.Append(";");
                }
            }
            else
            {
                stringBuilder.Append("no errors");
            }
            this.WriteError(new Exception(Strings.MsoObjectNotFound(syncObjectId.ToString(), stringBuilder.ToString())), ErrorCategory.ObjectNotFound, null, false);
        }
 public TenantSyncBatchResults(DirectoryObjectsAndLinks ObjectsAndLinks) : this()
 {
     base.Objects = ObjectsAndLinks.Objects;
     base.Links   = ObjectsAndLinks.Links;
     base.More    = ObjectsAndLinks.More;
     base.Errors  = ObjectsAndLinks.Errors;
 }
Ejemplo n.º 4
0
        public void Append(string executingUser, byte[] cookie, NameValueCollection parameters, object response, Dictionary <SyncObject, Exception> errors)
        {
            string responseIdentity = Guid.NewGuid().ToString("N");

            this.Append(BackSyncAuditLog.CreateLogRowForFirstLine(executingUser, cookie, parameters, responseIdentity));
            if (response is GetChangesResponse)
            {
                DirectoryChanges getChangesResult = ((GetChangesResponse)response).GetChangesResult;
                this.Append <DirectoryObject>(responseIdentity, getChangesResult.Objects);
                this.Append <DirectoryLink>(responseIdentity, getChangesResult.Links);
            }
            else
            {
                if (!(response is GetDirectoryObjectsResponse))
                {
                    throw new NotImplementedException("Need implement writing audit log for response type: " + response.GetType().Name);
                }
                DirectoryObjectsAndLinks getDirectoryObjectsResult = ((GetDirectoryObjectsResponse)response).GetDirectoryObjectsResult;
                this.Append <DirectoryObject>(responseIdentity, getDirectoryObjectsResult.Objects);
                this.Append <DirectoryLink>(responseIdentity, getDirectoryObjectsResult.Links);
                this.Append <DirectoryObjectError>(responseIdentity, getDirectoryObjectsResult.Errors);
            }
            this.Append(responseIdentity, errors);
        }
Ejemplo n.º 5
0
        internal MsoRawObject(SyncObjectId externalObjectId, string serviceInstanceId, DirectoryObjectsAndLinks directoryObjectsAndLinks, bool?allLinksCollected, bool populateRawObject) : this()
        {
            this.ExternalObjectId         = externalObjectId;
            this.ServiceInstanceId        = serviceInstanceId;
            this.SerializedObjectAndLinks = this.SerializeForRpsDelivery(directoryObjectsAndLinks);
            this.MySyncObject             = SyncObject.Create(directoryObjectsAndLinks.Objects[0], directoryObjectsAndLinks.Links, Guid.Empty);
            if (populateRawObject)
            {
                this.ObjectAndLinks = directoryObjectsAndLinks;
            }
            if (allLinksCollected != null)
            {
                this.AllLinksCollected = allLinksCollected;
                this.LinksCollected    = new int?((directoryObjectsAndLinks.Links == null) ? 0 : directoryObjectsAndLinks.Links.Length);
            }
            switch (externalObjectId.ObjectClass)
            {
            case DirectoryObjectClass.Account:
            {
                Account account = (Account)directoryObjectsAndLinks.Objects[0];
                if (account.DisplayName != null)
                {
                    this.DisplayName = account.DisplayName.Value[0];
                    return;
                }
                break;
            }

            case DirectoryObjectClass.Company:
            {
                Company company = (Company)directoryObjectsAndLinks.Objects[0];
                if (company.DisplayName != null)
                {
                    this.DisplayName = company.DisplayName.Value[0];
                }
                if (company.AssignedPlan != null)
                {
                    this.AssignedPlanCapabilities = this.CollectCapabilities(company.AssignedPlan.Value);
                    return;
                }
                break;
            }

            case DirectoryObjectClass.Contact:
            {
                Contact contact = (Contact)directoryObjectsAndLinks.Objects[0];
                if (contact.DisplayName != null)
                {
                    this.DisplayName = contact.DisplayName.Value[0];
                }
                if (contact.ValidationError != null && contact.ValidationError.Value != null)
                {
                    this.ExchangeValidationError = this.CollectErrorDetails(contact.ValidationError.Value);
                    return;
                }
                break;
            }

            case DirectoryObjectClass.Device:
            case DirectoryObjectClass.KeyGroup:
            case DirectoryObjectClass.ServicePrincipal:
            case DirectoryObjectClass.SubscribedPlan:
                break;

            case DirectoryObjectClass.ForeignPrincipal:
            {
                ForeignPrincipal foreignPrincipal = (ForeignPrincipal)directoryObjectsAndLinks.Objects[0];
                if (foreignPrincipal.DisplayName != null)
                {
                    this.DisplayName = foreignPrincipal.DisplayName.Value[0];
                    return;
                }
                break;
            }

            case DirectoryObjectClass.Group:
            {
                Group group = (Group)directoryObjectsAndLinks.Objects[0];
                if (group.DisplayName != null)
                {
                    this.DisplayName = group.DisplayName.Value[0];
                }
                if (group.ValidationError != null && group.ValidationError.Value != null)
                {
                    this.ExchangeValidationError = this.CollectErrorDetails(group.ValidationError.Value);
                }
                break;
            }

            case DirectoryObjectClass.User:
            {
                User user = (User)directoryObjectsAndLinks.Objects[0];
                if (user.DisplayName != null)
                {
                    this.DisplayName = user.DisplayName.Value[0];
                }
                if (user.WindowsLiveNetId != null)
                {
                    this.WindowsLiveNetId = new NetID(user.WindowsLiveNetId.Value[0]);
                }
                if (user.AssignedPlan != null)
                {
                    this.AssignedPlanCapabilities = this.CollectCapabilities(user.AssignedPlan.Value);
                }
                if (user.ValidationError != null && user.ValidationError.Value != null)
                {
                    this.ExchangeValidationError = this.CollectErrorDetails(user.ValidationError.Value);
                    return;
                }
                break;
            }

            default:
                return;
            }
        }
Ejemplo n.º 6
0
        public DirectoryObjectsAndLinks GetMsoRawObject(SyncObjectId syncObjectId, string serviceInstanceId, bool includeBackLinks, bool includeForwardLinks, int linksResultSize, out bool?allLinksCollected)
        {
            DirectoryObjectIdentity[] array = new DirectoryObjectIdentity[]
            {
                syncObjectId.ToMsoIdentity()
            };
            DirectoryObject[]        array2 = new DirectoryObject[1];
            DirectoryLink[]          array3 = new DirectoryLink[0];
            DirectoryObjectError[]   array4 = new DirectoryObjectError[0];
            DirectoryObjectsAndLinks directoryObjectsAndLinks = new DirectoryObjectsAndLinks
            {
                NextPageToken = null,
                More          = true
            };

            byte[] msoSyncCookie = this.GetMsoSyncCookie(serviceInstanceId);
            GetDirectoryObjectsOptions?getDirectoryObjectsOptions = new GetDirectoryObjectsOptions?(GetDirectoryObjectsOptions.None);

            if (includeBackLinks)
            {
                getDirectoryObjectsOptions |= GetDirectoryObjectsOptions.IncludeBackLinks;
            }
            if (includeForwardLinks)
            {
                getDirectoryObjectsOptions |= GetDirectoryObjectsOptions.IncludeForwardLinks;
            }
            if (includeForwardLinks || includeBackLinks)
            {
                allLinksCollected = new bool?(true);
            }
            else
            {
                allLinksCollected = null;
            }
            while (directoryObjectsAndLinks.More)
            {
                GetDirectoryObjectsRequest  request          = new GetDirectoryObjectsRequest((directoryObjectsAndLinks.NextPageToken == null) ? msoSyncCookie : null, (directoryObjectsAndLinks.NextPageToken == null) ? array : null, (directoryObjectsAndLinks.NextPageToken == null) ? getDirectoryObjectsOptions : null, directoryObjectsAndLinks.NextPageToken);
                GetDirectoryObjectsResponse directoryObjects = this.SyncProxy.GetDirectoryObjects(request);
                if (directoryObjects.GetDirectoryObjectsResult.Objects != null && directoryObjects.GetDirectoryObjectsResult.Objects.Length != 0 && array2[0] == null)
                {
                    directoryObjects.GetDirectoryObjectsResult.Objects.CopyTo(array2, 0);
                }
                if (allLinksCollected == true && directoryObjects.GetDirectoryObjectsResult.Links != null && directoryObjects.GetDirectoryObjectsResult.Links.Length != 0 && array3.Length <= linksResultSize)
                {
                    if (array3.Length == linksResultSize)
                    {
                        allLinksCollected = new bool?(false);
                    }
                    else
                    {
                        int num  = array3.Length;
                        int num2 = array3.Length + directoryObjects.GetDirectoryObjectsResult.Links.Length;
                        int num3 = Math.Min(linksResultSize, num2);
                        if (num2 > linksResultSize)
                        {
                            allLinksCollected = new bool?(false);
                        }
                        Array.Resize <DirectoryLink>(ref array3, num3);
                        Array.Copy(directoryObjects.GetDirectoryObjectsResult.Links, 0, array3, num, num3 - num);
                    }
                }
                if (directoryObjects.GetDirectoryObjectsResult.Errors != null && directoryObjects.GetDirectoryObjectsResult.Errors.Length != 0)
                {
                    Array.Resize <DirectoryObjectError>(ref array4, array4.Length + directoryObjects.GetDirectoryObjectsResult.Errors.Length);
                    directoryObjects.GetDirectoryObjectsResult.Errors.CopyTo(array4, array4.Length - directoryObjects.GetDirectoryObjectsResult.Errors.Length);
                }
                directoryObjectsAndLinks.NextPageToken = directoryObjects.GetDirectoryObjectsResult.NextPageToken;
                directoryObjectsAndLinks.More          = directoryObjects.GetDirectoryObjectsResult.More;
            }
            directoryObjectsAndLinks.Objects = ((array2 != null && array2[0] != null) ? array2 : new DirectoryObject[0]);
            directoryObjectsAndLinks.Links   = array3;
            directoryObjectsAndLinks.Errors  = array4;
            return(directoryObjectsAndLinks);
        }