Esempio n. 1
0
        private GetGroupResponse GetDLData()
        {
            GetGroupResponse  getGroupResponse            = new GetGroupResponse();
            ADRecipient       adrecipient                 = null;
            IRecipientSession galscopedADRecipientSession = base.CallContext.ADRecipientSessionContext.GetGALScopedADRecipientSession(base.CallContext.EffectiveCaller.ClientSecurityContext);

            if (!string.IsNullOrEmpty(this.smtpAddress))
            {
                Directory.TryFindRecipient(this.smtpAddress, galscopedADRecipientSession, out adrecipient);
            }
            if (adrecipient == null)
            {
                if (!string.IsNullOrEmpty(this.adObjectId))
                {
                    Guid guid = new Guid(this.adObjectId);
                    adrecipient = galscopedADRecipientSession.FindByObjectGuid(guid);
                }
                else if (!string.IsNullOrEmpty(this.legacyExchangeDN))
                {
                    adrecipient = galscopedADRecipientSession.FindByLegacyExchangeDN(this.legacyExchangeDN);
                }
            }
            ADGroup adgroup = adrecipient as ADGroup;

            if (adgroup != null)
            {
                IADDistributionList iaddistributionList = adgroup;
                if (iaddistributionList != null)
                {
                    if (this.IsGeneralInfoInResultSet)
                    {
                        getGroupResponse.Description = adgroup.Description;
                        getGroupResponse.Notes       = adrecipient.Notes;
                        this.SetOwners(galscopedADRecipientSession, iaddistributionList, getGroupResponse);
                    }
                    if (this.IsMembersInResultSet)
                    {
                        getGroupResponse.MembersCount = ((iaddistributionList.Members != null) ? iaddistributionList.Members.Count : 0);
                        this.WriteDebugTrace("Total DL members count is " + getGroupResponse.MembersCount);
                        if (adrecipient.RecipientType != RecipientType.DynamicDistributionGroup)
                        {
                            if (getGroupResponse.MembersCount > 0)
                            {
                                this.SetMembers(galscopedADRecipientSession, iaddistributionList, getGroupResponse);
                            }
                        }
                        else
                        {
                            this.WriteDebugTrace("DDL - Members information is not loaded");
                        }
                    }
                }
                else
                {
                    this.WriteDebugTrace("No DL was found");
                }
            }
            else
            {
                this.WriteDebugTrace("The AD recipient is not a DL");
            }
            return(getGroupResponse);
        }