/// <summary>Enumerates a domain group.</summary>
        public override DomainGroupEnumeratorResults EnumerateGroup(SPUser domainGroup, SPWeb web, TimeSpan timeRemaining, bool hideDisabledUsers)
        {
            DomainGroupEnumeratorResults results = new DomainGroupEnumeratorResults();

            results.IncludeGroup = false;
            return(results);
        }
Exemplo n.º 2
0
        /// <summary>Enumerates the members of a domain group. </summary>
        /// <param name="spWeb">An <c>SPWeb</c> within the site collection to which users from the domain group will be added as needed.</param>
        /// <param name="domainGroup">The <c>SPUser</c> representing the domain group to enumerate.</param>
        /// <param name="isInstructor"><c>true</c> if this domain group has the "SLK Instructor" permission.</param>
        /// <param name="isLearner"><c>true</c> if this domain group has the "SLK Learner" permission.</param>
        /// <param name="learnerKeys">The SLK "user key" (e.g. SID or login name) of each learner is
        ///     added to this collection, unless <paramref name="learnerKeys"/> is <c>null</c>.</param>
        /// <param name="hideDisabledUsers">Whether to hide disabled users or not.</param>
        /// <returns><c>true</c> if enumeration succeeds, <c>false</c> if not. </returns>
        void EnumerateDomainGroupMembers(SPWeb spWeb, SPUser domainGroup, bool isInstructor, bool isLearner, List <string> learnerKeys, bool hideDisabledUsers)
        {
            // if timeout occurred, output a message to <groupFailureDetailsBuilder>
            TimeSpan timeRemaining = DomainGroupEnumerationTotalTimeout - (DateTime.Now - startTime);

            if (timeRemaining <= TimeSpan.Zero)
            {
                AddGroupFailureDetail(culture.Resources.DomainGroupEnumSkippedDueToTimeout, domainGroup.LoginName);
                return;
            }

            DomainGroupEnumeratorResults results = DomainGroupEnumerator.EnumerateGroup(domainGroup, spWeb, timeRemaining, hideDisabledUsers);

            if (results.Errors.Count > 0)
            {
                groupFailuresList.Add(domainGroup.Name);
                foreach (String error in results.Errors)
                {
                    AddGroupFailureDetail(culture.Resources.DomainGroupError, domainGroup.LoginName, error);
                }

                StringBuilder detailedErrorBuilder = new StringBuilder();
                foreach (Exception e in results.DetailedExceptions)
                {
                    detailedErrorBuilder.Append(e.ToString());
                    detailedErrorBuilder.Append(Environment.NewLine);
                }

                store.LogError(detailedErrorBuilder.ToString());
            }

            // If a learner then create a new learner group and add to the collection of learner groups
            SlkGroup learnerGroup = null;

            if (isLearner && (learnerGroups != null))
            {
                learnerGroup          = new SlkGroup(null, domainGroup);
                learnerGroup.UserKeys = new List <string>(results.Users.Count);
                learnerGroups.Add(learnerGroup);
            }

            // add users from the domain group to the collections of instructors, learners, and/or this learner group, as appropriate
            foreach (SPUser spUserInGroup in results.Users)
            {
                AddUser(spUserInGroup, isInstructor, isLearner, learnerGroup, learnerKeys);
            }

            return;
        }
Exemplo n.º 3
0
        /// <summary>Enumerates a domain group.</summary>
        public override DomainGroupEnumeratorResults EnumerateGroup(SPUser domainGroup, SPWeb web, TimeSpan timeRemaining, bool hideDisabledUsers)
        {
            DomainGroupEnumeratorResults results     = new DomainGroupEnumeratorResults();
            ICollection <SPUserInfo>     spUserInfos = new List <SPUserInfo>();

            try
            {
                DomainGroupUtilities enumerateDomainGroups = new DomainGroupUtilities(timeRemaining, hideDisabledUsers);
                spUserInfos = enumerateDomainGroups.EnumerateDomainGroup(domainGroup);

                foreach (string error in enumerateDomainGroups.Errors)
                {
                    results.Errors.Add(error);
                }
            }
            catch (DomainGroupEnumerationException exception)
            {
                results.Errors.Add(exception.Message);
                if (exception.InnerException != null)
                {
                    results.DetailedExceptions.Add(exception.InnerException);
                }
            }

            foreach (SPUserInfo spUserInfo in spUserInfos)
            {
                try
                {
                    SPUser spUserInGroup = web.EnsureUser(spUserInfo.LoginName);
                    results.Users.Add(spUserInGroup);
                }
                catch (SPException exception)
                {
                    SlkCulture culture = new SlkCulture();
                    results.Errors.Add(string.Format(culture.Culture, culture.Resources.ErrorCreatingSPSiteUser, web.Site.Url, exception));
                }
            }

            return(results);
        }