public void MSCPSWS_S02_TC03_GetHierarchy_ValidNumberOfLevels()
        {
            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType         = SPPrincipalType.SharePointGroup;
            string          providerName          = null;
            bool            isGetHierarchySuccess = false;

            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (provider.ProviderName != null && !provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    providerName = provider.ProviderName;

                    // Call GetHierarchy method to get a claims provider hierarchy tree with a valid numberOfLevels parameter in the request.
                    SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, null, numberOfLevels);
                    Site.Assert.IsNotNull(responseOfGetHierarchyResult, "If the numberOfLevels is a valid value, the protocol server MUST use the current available claims providers.");
                    isGetHierarchySuccess = true;

                    // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isGetHierarchySuccess,
                        194,
                        @"[In GetHierarchy] The protocol server MUST retrieve a claims provider hierarchy tree from the claims provider that meets all the following criteria:
The claims provider name is specified in the input message.
The claims provider is associated with the Web application (1) specified in the input message.
The claims provider supports hierarchy.");
                }
            }
        }
Esempio n. 2
0
    /// <summary>
    /// Start search operation on a specific claims provider
    /// </summary>
    /// <param name="inputValue"></param>
    /// <param name="expectedCount">How many entities are expected to be returned. Set to Int32.MaxValue if exact number is unknown but greater than 0</param>
    /// <param name="expectedClaimValue"></param>
    public static void TestSearchOperation(string inputValue, int expectedCount, string expectedClaimValue)
    {
        try
        {
            Stopwatch timer = new Stopwatch();
            timer.Start();
            var entityTypes = new[] { "User", "SecGroup", "SharePointGroup", "System", "FormsRole" };

            SPProviderHierarchyTree providerResults = ClaimsProvider.Search(TestSiteCollUri, entityTypes, inputValue, null, 30);
            List <PickerEntity>     entities        = new List <PickerEntity>();
            foreach (var children in providerResults.Children)
            {
                entities.AddRange(children.EntityData);
            }
            VerifySearchTest(entities, inputValue, expectedCount, expectedClaimValue);

            entities = ClaimsProvider.Resolve(TestSiteCollUri, entityTypes, inputValue).ToList();
            VerifySearchTest(entities, inputValue, expectedCount, expectedClaimValue);
            timer.Stop();
            Trace.WriteLine($"{DateTime.Now.ToString("s")} TestSearchOperation finished in {timer.ElapsedMilliseconds} ms. Parameters: inputValue: '{inputValue}', expectedCount: '{expectedCount}', expectedClaimValue: '{expectedClaimValue}'.");
        }
        catch (Exception ex)
        {
            Trace.TraceError($"{DateTime.Now.ToString("s")} TestSearchOperation failed with exception '{ex.GetType()}', message '{ex.Message}'. Parameters: inputValue: '{inputValue}', expectedCount: '{expectedCount}', expectedClaimValue: '{expectedClaimValue}'.");
        }
    }
        public void MSCPSWS_S02_TC02_GetHierarchy_ValidHierarchyNodeID()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType   = SPPrincipalType.SharePointGroup;
            string          providerName    = null;
            string          hierarchyNodeID = null;

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (provider.ProviderName != null && !provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    providerName = provider.ProviderName;

                    foreach (SPProviderHierarchyNode children in provider.Children)
                    {
                        if (children.HierarchyNodeID != null)
                        {
                            hierarchyNodeID = children.HierarchyNodeID;
                        }
                    }

                    if (providerName != null && hierarchyNodeID != null)
                    {
                        break;
                    }
                }
            }

            Site.Assert.IsNotNull(providerName, "No such claim provider which have a hierarchyNodeID exists in the server!");
            Site.Assert.IsNotNull(hierarchyNodeID, "No such claim provider which have a hierarchyNodeID exists in the server!");

            // Call GetHierarchy method to get a claims provider hierarchy tree with a valid child hierarchyNodeID in the request.
            SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, hierarchyNodeID, numberOfLevels);

            Site.Assert.AreEqual <string>("false", responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture), "Should return the hierarchyNodeID specified claims provider hierarchy tree, which is not existing root of current claims provider hierarchy tree.");

            // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture) == "false",
                194,
                @"[In GetHierarchy] The protocol server MUST retrieve a claims provider hierarchy tree from the claims provider that meets all the following criteria:
The claims provider name is specified in the input message.
The claims provider is associated with the Web application (1) specified in the input message.
The claims provider supports hierarchy.");

            // If the providerName is not null, then the protocol server retrieve a hierarchy provider hierarchy tree in the input message, then the following requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                providerName,
                194001,
                @"[In GetHierarchy] The protocol server MUST retrieve a hierarchy provider hierarchy tree if the name of an available hierarchy provider is specified in the input message.");
        }
Esempio n. 4
0
    /// <summary>
    /// Start search operation on a specific claims provider
    /// </summary>
    /// <param name="inputValue"></param>
    /// <param name="expectedCount">How many entities are expected to be returned. Set to Int32.MaxValue if exact number is unknown but greater than 0</param>
    /// <param name="expectedClaimValue"></param>
    public static void TestSearchOperation(string inputValue, int expectedCount, string expectedClaimValue)
    {
        string[] entityTypes = new string[] { "User", "SecGroup", "SharePointGroup", "System", "FormsRole" };

        SPProviderHierarchyTree providerResults = ClaimsProvider.Search(TestSiteCollUri, entityTypes, inputValue, null, 30);
        List <PickerEntity>     entities        = new List <PickerEntity>();

        foreach (var children in providerResults.Children)
        {
            entities.AddRange(children.EntityData);
        }
        VerifySearchTest(entities, inputValue, expectedCount, expectedClaimValue);

        entities = ClaimsProvider.Resolve(TestSiteCollUri, entityTypes, inputValue).ToList();
        VerifySearchTest(entities, inputValue, expectedCount, expectedClaimValue);
    }
        public void MSCPSWS_S02_TC01_GetHierarchy_NullHierarchyNodeID()
        {
            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType = SPPrincipalType.SharePointGroup;
            string          providerName  = null;

            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (!provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)) && provider.Children.Length != 0)
                {
                    providerName = provider.ProviderName;
                    //Verify MS-CPSWS requirement: MS-CPSWS_R540001
                    Site.CaptureRequirementIfIsTrue(
                        provider.HierarchyNodeID.Length == 0,
                        540001,
                        @"[In SPProviderHierarchyElement] This value[HierarchyNodeID] is empty for the hierarchy provider and the root element of the hierarchy tree.");

                    if (providerName != null)
                    {
                        break;
                    }
                }
            }

            Site.Assume.IsNotNull(providerName, "The providerName should not be null!");

            // Call GetHierarchy method to get a claims provider hierarchy tree with a null hierarchyNodeID in the request.
            SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, null, numberOfLevels);

            Site.Assert.AreEqual <string>("true", responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture), "Should return the existing root of current claims provider hierarchy tree.");

            // Verify MS-CPSWS requirement: MS-CPSWS_R209
            Site.CaptureRequirementIfAreEqual <string>(
                "true",
                responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture),
                209,
                @"[In GetHierarchy] hierarchyNodeID: If NULL is specified, then the protocol server MUST return the existing root of claims provider hierarchy tree.");
        }
Esempio n. 6
0
        /// <summary>
        /// A method used to retrieve a list of claims provider hierarchy trees from a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] GetHierarchyAll(ArrayOfString providerNames, SPPrincipalType principalType, int numberOfLevels)
        {
            SPProviderHierarchyTree[] responseOfGetHierarchyAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfGetHierarchyAll = this.cpswsClient.GetHierarchyAll(providerNames, principalType, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [GetHierarchyAll] method:\r\n{0}",
                    faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyAllResponseData(responseOfGetHierarchyAll);

            return(responseOfGetHierarchyAll);
        }
Esempio n. 7
0
        /// <summary>
        /// A method used to perform a search for entities on a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="searchPattern">A parameter represents the search string.</param>
        /// <param name="maxCount">A parameter represents the maximum number of matched entities to be returned in total across all the output claims provider hierarchy trees.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] SearchAll(ArrayOfString providerNames, SPPrincipalType principalType, string searchPattern, int maxCount)
        {
            SPProviderHierarchyTree[] responseOfSearchAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfSearchAll = this.cpswsClient.SearchAll(providerNames, principalType, searchPattern, maxCount);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [SearchAll] method:\r\n{0}",
                    faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.VerifySearchAll(responseOfSearchAll);

            return(responseOfSearchAll);
        }
        protected override void FillSearch(Uri context, string[] entityTypes,string searchPattern, string hierarchyNodeID, int maxCount,SPProviderHierarchyTree searchTree)
        {
            // Ensure that People Picker is asking for the type of entity that we
            // return; site collection administrator will not return, for example.
            if (!EntityTypesContain(entityTypes, SPClaimEntityTypes.FormsRole))
                return;

            // The counter to track what node we are in; it will be used to call into
            // our helper arrays that were covered in part 1 and part 2 of this article.
            int teamNode = -1;

            SPProviderHierarchyNode matchNode = null;
            //Query ActiveDirectory for a user or a group with a name like the search string
            var adTools = new ActiveDirectory();
            var users = adTools.FindUsers(searchPattern);

            foreach (var user in users)
            {
                matchNode.AddEntity(GetPickerEntity(user));
            }
        }
        protected override void FillSearch(
            Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount,
            SPProviderHierarchyTree searchTree)
        {
            var users = GetUsers(searchPattern);

            foreach (var user in users)
                searchTree.AddEntity(GetPickerEntity(ClaimType.UPN, user.userName, user.email));
        }
        //provides the People Picker control with the ability to load portions of 
        //the[T:HYPERLINK"ms-help://MS.SPF14SDK.en/SPF14MrefControls/html/a4bf54d0-29e5-e5c2-231e-b1b9f4728a7f.htm
        //"Microsoft.SharePoint.WebControls.SPProviderHierarchyTree] tree from the claims provider and specifies the hierarchy for displaying the picker entities.
        protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy)
        {
            if (!EntityTypesContain(entityTypes, SPClaimEntityTypes.FormsRole))
            {
                return;
            }
            if (hierarchyNodeID == null)
            {
                int numberOfKeys = clearanceKeys.Length;
                for (int i = 0; i < numberOfKeys; i++)
                {
                    hierarchy.AddChild(
                        new Microsoft.SharePoint.WebControls.SPProviderHierarchyNode(
                            SecurityClearanceCP.ProviderInternalName,
                            clearanceLabels[i],
                            clearanceKeys[i],
                            true


                   ));
                }
            }
        }
 // fills search results in People Picker control window.
 protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree)
 {
     throw new NotImplementedException();
 }
Esempio n. 12
0
        /// <summary>
        /// A method used to validate the GetHierarchyAll response. 
        /// </summary>
        /// <param name="getHierarchyAllResult">A parameter represents the GetHierarchyAll result.</param> 
        private void ValidateGetHierarchyAllResponseData(SPProviderHierarchyTree[] getHierarchyAllResult)
        {
            XmlElement xmlResponse = SchemaValidation.LastRawResponseXml;
            bool isResponseValid = SchemaValidation.ValidationResult == ValidationResult.Success;
            bool isPrefix = false;

            // The response have been received successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                217,
                @"[In GetHierarchyAll] The following is the WSDL port type specification of the GetHierarchyAll WSDL operation.
<wsdl:operation name=""GetHierarchyAll"" xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"">
  <wsdl:input wsaw:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/GetHierarchyAll"" message=""tns:IClaimProviderWebService_GetHierarchyAll_InputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
  <wsdl:output wsaw:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/GetHierarchyAllResponse"" message=""tns:IClaimProviderWebService_GetHierarchyAll_OutputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
</wsdl:operation>");

            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                218,
                @"[In GetHierarchyAll] The protocol client sends an IClaimProviderWebService_GetHierarchyAll_InputMessage (section 3.1.4.5.1.1) request WSDL message and the protocol server responds with an IClaimProviderWebService_GetHierarchyAll_OutputMessage (section 3.1.4.5.1.2) response message.");

            // If the server response is validated successfully, and the GetHierarchyAllResponse has returned, MS-CPSWS_R228 can be verified.
            Site.CaptureRequirementIfIsTrue(
                this.ResponseExists(xmlResponse, "GetHierarchyAllResponse"),
                228,
                @"[In IClaimProviderWebService_GetHierarchyAll_OutputMessage] The [GetHierarchyAll]  SOAP body contains the GetHierarchyAllResponse element.");

            // The response have been received successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                237,
                @"[In GetHierarchyAllResponse] The GetHierarchyAllResponse element specifies the result data for the GetHierarchyAll WSDL operation.
<xs:element name=""GetHierarchyAllResponse"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs=""0"" maxOccurs=""1"" name=""GetHierarchyAllResult"" type=""tns:ArrayOfSPProviderHierarchyTree""/>
    </xs:sequence>
  </xs:complexType>
</xs:element>");

            if (getHierarchyAllResult.Length != 0)
            {
                this.VerifyArrayOfSPProviderHierarchyTreeComplexType(getHierarchyAllResult);
            }
            string namePrefixed = Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site);
            foreach (SPProviderHierarchyTree element in getHierarchyAllResult)
            {
                if (element.ProviderName.StartsWith(namePrefixed))
                {
                    isPrefix = true;
                    break;
                }
            }
           Site.CaptureRequirementIfIsTrue(
                isPrefix,
                584001,
                @"[In GetHierarchyAll] The name of the hierarchy provider is prefixed with ""_HierarchyProvider_"".");
        }
        /// <summary>
        /// A method used to perform a search for entities on a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="searchPattern">A parameter represents the search string.</param>
        /// <param name="maxCount">A parameter represents the maximum number of matched entities to be returned in total across all the output claims provider hierarchy trees.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] SearchAll(ArrayOfString providerNames, SPPrincipalType principalType, string searchPattern, int maxCount)
        {
            SPProviderHierarchyTree[] responseOfSearchAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfSearchAll = this.cpswsClient.SearchAll(providerNames, principalType, searchPattern, maxCount);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [SearchAll] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.VerifySearchAll(responseOfSearchAll);

            return responseOfSearchAll;
        }
        protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree)
        {
            if (!this.SetSPTrustInCurrentContext(context))
            {
                return;
            }

            SPProviderHierarchyNode matchNode = null;
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                this.InitializeAuth0Client();
                var consolidatedResults = this.ResolveInputBulk(searchPattern, hierarchyNodeID);

                if (consolidatedResults != null)
                {
                    if (string.IsNullOrEmpty(searchPattern))
                    {
                        // All users from specific connection(s)
                        var results = this.CreateAllUsersResults(hierarchyNodeID);
                        results.ToList().ForEach(
                            r => consolidatedResults.Add(r));
                    }
                    else if (this.alwaysResolveValue &&
                             Utils.ValidEmail(searchPattern) &&
                             !consolidatedResults.Any(
                                r => r.Auth0User.Email.Equals(searchPattern, StringComparison.OrdinalIgnoreCase) &&
                                     r.Attribute.PeoplePickerAttributeHierarchyNodeId == hierarchyNodeID))
                    {
                        // Specific email from specific connection
                        var result = this.CreateUniqueResult(searchPattern, UsersNode);
                        consolidatedResults.Add(result);
                    }

                    if (consolidatedResults.Count > 0)
                    {
                        foreach (var consolidatedResult in consolidatedResults)
                        {
                            // Add current PickerEntity to the corresponding attribute in the hierarchy
                            if (!searchTree.HasChild(UsersNode))
                            {
                                matchNode = new SPProviderHierarchyNode(
                                    ProviderInternalName,
                                    consolidatedResult.Attribute.PeoplePickerAttributeDisplayName,
                                    consolidatedResult.Attribute.PeoplePickerAttributeHierarchyNodeId,
                                    true);

                                searchTree.AddChild(matchNode);
                            }

                            matchNode.AddEntity(consolidatedResult.PickerEntity);
                        }

                        return;
                    }
                }
            });
        }
        /// <summary>
        /// A method used to retrieve a list of claims provider hierarchy trees from a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] GetHierarchyAll(ArrayOfString providerNames, SPPrincipalType principalType, int numberOfLevels)
        {
            SPProviderHierarchyTree[] responseOfGetHierarchyAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfGetHierarchyAll = this.cpswsClient.GetHierarchyAll(providerNames, principalType, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [GetHierarchyAll] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyAllResponseData(responseOfGetHierarchyAll);

            return responseOfGetHierarchyAll;
        }
        protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree)
        {
            if (!this.SetSPTrustInCurrentContext(context))
            {
                return;
            }

            SPProviderHierarchyNode matchNode = null;

            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                this.InitializeAuth0Client();
                var consolidatedResults = this.ResolveInputBulk(searchPattern, hierarchyNodeID);

                if (consolidatedResults != null)
                {
                    if (string.IsNullOrEmpty(searchPattern))
                    {
                        // All users from specific connection(s)
                        var results = this.CreateAllUsersResults(hierarchyNodeID);
                        results.ToList().ForEach(
                            r => consolidatedResults.Add(r));
                    }
                    else if (this.alwaysResolveValue &&
                             Utils.ValidEmail(searchPattern) &&
                             !consolidatedResults.Any(
                                 r => r.Auth0User.Email.Equals(searchPattern, StringComparison.OrdinalIgnoreCase) &&
                                 r.Attribute.PeoplePickerAttributeHierarchyNodeId == hierarchyNodeID))
                    {
                        // Specific email from specific connection
                        var result = this.CreateUniqueResult(searchPattern, UsersNode);
                        consolidatedResults.Add(result);
                    }

                    if (consolidatedResults.Count > 0)
                    {
                        foreach (var consolidatedResult in consolidatedResults)
                        {
                            // Add current PickerEntity to the corresponding attribute in the hierarchy
                            if (!searchTree.HasChild(UsersNode))
                            {
                                matchNode = new SPProviderHierarchyNode(
                                    ProviderInternalName,
                                    consolidatedResult.Attribute.PeoplePickerAttributeDisplayName,
                                    consolidatedResult.Attribute.PeoplePickerAttributeHierarchyNodeId,
                                    true);

                                searchTree.AddChild(matchNode);
                            }

                            matchNode.AddEntity(consolidatedResult.PickerEntity);
                        }

                        return;
                    }
                }
            });
        }
        protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy)
        {
            if (!this.SetSPTrustInCurrentContext(context))
            {
                return;
            }

            hierarchy.AddChild(new
                               Microsoft.SharePoint.WebControls.SPProviderHierarchyNode(
                                   ProviderInternalName, UsersNode, UsersNode, true));
        }
Esempio n. 18
0
        /// <summary>
        /// A method used to verify the Search response. 
        /// </summary>
        /// <param name="searchResult">A parameter represents the Search result.</param> 
        private void VerifySearch(SPProviderHierarchyTree[] searchResult)
        {
            XmlElement xmlResponse = SchemaValidation.LastRawResponseXml;
            bool isResponseValid = SchemaValidation.ValidationResult == ValidationResult.Success;

            if (this.ResponseExists(xmlResponse, "SearchResponse"))
            {
                // The response have been received successfully, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    376,
                    @"[In Search] The following is the WSDL port type specification of the Search WSDL operation.
<wsdl:operation name=""Search"" xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"">
  <wsdl:input wsam:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/Search"" message=""tns:IClaimProviderWebService_Search_InputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
  <wsdl:output wsam:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/SearchResponse"" message=""tns:IClaimProviderWebService_Search_OutputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
</wsdl:operation>");

                // The response have been received successfully, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    377,
                    @"[In Search] The protocol client sends an IClaimProviderWebService_Search_InputMessage (section 3.1.4.12.1.1) request WSDL message and the protocol server responds with an IClaimProviderWebService_Search_OutputMessage (section 3.1.4.12.1.2) response message.");

                // If the response is contained in the response raw XML, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    this.ResponseExists(xmlResponse, "SearchResponse"),
                    387,
                    @"[In IClaimProviderWebService_Search_OutputMessage] The SOAP body contains the SearchResponse element.");

                // The response have been received successfully, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    399,
                    @"[In SearchResponse] The SearchResponse element specifies the result data for the Search WSDL operation.
<xs:element name=""SearchResponse"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs=""0"" maxOccurs=""1"" name=""SearchResult"" type=""tns:ArrayOfSPProviderHierarchyTree""/>
    </xs:sequence>
  </xs:complexType>
</xs:element>");

                if (searchResult != null)
                {
                    this.VerifyArrayOfSPProviderHierarchyTreeComplexType(searchResult);
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// A method used to verify the ArrayOfSPProviderHierarchyTree complex type.
        /// </summary>
        /// <param name="providerHierarchyTreeArray">A parameter represents a list of the SPProviderHierarchyTree.</param>
        private void VerifyArrayOfSPProviderHierarchyTreeComplexType(SPProviderHierarchyTree[] providerHierarchyTreeArray)
        {
            bool isResponseValid = SchemaValidation.ValidationResult == ValidationResult.Success;
            if (providerHierarchyTreeArray != null)
            {
                // If the response passed XML validation, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    39,
                    @"[In ArrayOfSPProviderHierarchyTree] ArrayOfSPProviderHierarchyTree: An array of elements of type SPProviderHierarchyTree (section 2.2.4.13).
<xs:complexType name=""ArrayOfSPProviderHierarchyTree"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:sequence>
    <xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SPProviderHierarchyTree"" nillable=""true"" type=""tns:SPProviderHierarchyTree""/>
  </xs:sequence>
</xs:complexType>");

                if (providerHierarchyTreeArray.Length > 0)
                {
                    foreach (SPProviderHierarchyTree providerHierarchyTree in providerHierarchyTreeArray)
                    {
                        this.VerifySPProviderHierarchyTreeComplexType(providerHierarchyTree);
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// A method used to verify the SPProviderHierarchyTree complex type.
        /// </summary>
        /// <param name="providerHierarchyTree">A parameter represents an instance of SPProviderHierarchyTree.</param>
        private void VerifySPProviderHierarchyTreeComplexType(SPProviderHierarchyTree providerHierarchyTree)
        {
            bool isResponseValid = SchemaValidation.ValidationResult == ValidationResult.Success;
            if (providerHierarchyTree != null)
            {
                // If the response passed XML validation, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    71,
                    @"[In SPProviderHierarchyTree] A claim provider hierarchy tree.
<xs:complexType name=""SPProviderHierarchyTree"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexContent mixed=""false"">
    <xs:extension base=""tns:SPProviderHierarchyElement"">
      <xs:sequence>
        <xs:element minOccurs=""1"" maxOccurs=""1"" name=""IsRoot"" type=""xs:boolean""/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>");

                // If the response passed XML validation, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    isResponseValid,
                    537,
                    @"[In SPProviderHierarchyElement] SPProviderHierarchyElement: Defines the base type for SPProviderHierarchyNode and SPProviderHierarchyTree.
<xs:complexType name=""SPProviderHierarchyElement"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:sequence>
    <xs:element minOccurs=""0"" maxOccurs=""1"" name=""Nm"" type=""xs:string""/>
    <xs:element minOccurs=""0"" maxOccurs=""1"" name=""ProviderName"" type=""xs:string""/>
    <xs:element minOccurs=""0"" maxOccurs=""1"" name=""HierarchyNodeID"" type=""xs:string""/>
    <xs:element minOccurs=""1"" maxOccurs=""1"" name=""IsLeaf"" type=""xs:boolean""/>
    <xs:element minOccurs=""0"" maxOccurs=""1"" name=""Children"" type=""tns:ArrayOfSPProviderHierarchyNode""/>
    <xs:element minOccurs=""0"" maxOccurs=""1"" name=""EntityData"" type=""tns:ArrayOfPickerEntity""/>
    <xs:element minOccurs=""1"" maxOccurs=""1"" name=""Count"" type=""xs:int""/>
  </xs:sequence>
</xs:complexType>");
                if (providerHierarchyTree.Children != null)
                {
                    // If the response passed XML validation, then the following requirement can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isResponseValid,
                        516,
                        @"[In ArrayOfSPProviderHierarchyNode] An array of elements of type SPProviderHierarchyNode (section 2.2.4.12).
 <xs:complexType name=""ArrayOfSPProviderHierarchyNode"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:sequence>
    <xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SPProviderHierarchyNode"" nillable=""true"" type=""tns:SPProviderHierarchyNode""/>
  </xs:sequence>
</xs:complexType>");

                    // If the response passed XML validation, then the following requirement can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isResponseValid,
                        516,
                        @"[In ArrayOfSPProviderHierarchyNode] An array of elements of type SPProviderHierarchyNode (section 2.2.4.12).
 <xs:complexType name=""ArrayOfSPProviderHierarchyNode"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:sequence>
    <xs:element minOccurs=""0"" maxOccurs=""unbounded"" name=""SPProviderHierarchyNode"" nillable=""true"" type=""tns:SPProviderHierarchyNode""/>
  </xs:sequence>
</xs:complexType>");
                    if (providerHierarchyTree.Children.Length > 0)
                    {
                        // If the response passed XML validation, then the following requirement can be captured.
                        Site.CaptureRequirementIfIsTrue(
                            isResponseValid,
                            549,
                            @"[In SPProviderHierarchyNode] A claims provider hierarchy node.
<xs:complexType name=""SPProviderHierarchyNode"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexContent mixed=""false"">
    <xs:extension base=""tns:SPProviderHierarchyElement""/>
  </xs:complexContent>
</xs:complexType>");
                    }
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Required if you implement claims search in the People Picker.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="entityTypes"></param>
        /// <param name="searchPattern"></param>
        /// <param name="hierarchyNodeID"></param>
        /// <param name="maxCount"></param>
        /// <param name="searchTree"></param>
        protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree)
        {
            string        keyword         = searchPattern.ToLower();
            Hashtable     knownClaims     = CRMUserInfo.GetAllClaims();
            List <string> knownClaimsList = new List <string>();

            //Convert the knownClaims.Key into a List<string> for LINQ query.
            foreach (string claim in knownClaims.Keys)
            {
                knownClaimsList.Add(claim);
            }


            var claimQuery = knownClaimsList.Where(claim => claim.IndexOf(keyword) >= 0).Select(claim => claim);

            foreach (string claimValue in claimQuery)
            {
                //Get the ClaimType for the claim type.
                //For example, if you search "SalesManager", the ClaimType will be CRMClaimType.Role.

                string claimType = CRMUserInfo.GetClaimTypeForRole((string)knownClaims[claimValue]);

                PickerEntity entity = CreatePickerEntity();
                entity.Claim       = CreateClaim(claimType, claimValue, Microsoft.IdentityModel.Claims.ClaimValueTypes.String);
                entity.Description = claimValue;
                entity.DisplayText = claimValue;
                entity.EntityData[PeopleEditorEntityDataKeys.DisplayName] = claimValue;
                entity.EntityType = SPClaimEntityTypes.FormsRole;
                entity.IsResolved = true;
                searchTree.AddEntity(entity);
            }
        }
        protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy)
        {
            if (!this.SetSPTrustInCurrentContext(context))
            {
                return;
            }

            hierarchy.AddChild(new
                    Microsoft.SharePoint.WebControls.SPProviderHierarchyNode(
                        ProviderInternalName, UsersNode, UsersNode, true));
        }
 protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree) {
     if (!EntityTypesContain(entityTypes, SPClaimEntityTypes.FormsRole)) {
         return;
     }
     var user = new SiteUser() {
         LoginName = searchPattern,
         DisplayName = searchPattern
     };
     PickerEntity entity = GetPickerEntity(user);
     searchTree.AddEntity(entity);
 }
 protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy)
 {
     throw new NotImplementedException();
 }
 protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy) {
     throw new NotImplementedException();
 }
        /// <summary>
        /// A method used to retrieve a claims provider hierarchy tree from a claims provider.
        /// </summary>
        /// <param name="providerName">A parameter represents a provider name.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="hierarchyNodeID">A parameter represents the identifier of the node to be used as root of the returned claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a claims provider hierarchy tree.</returns>
        public SPProviderHierarchyTree GetHierarchy(string providerName, SPPrincipalType principalType, string hierarchyNodeID, int numberOfLevels)
        {
            SPProviderHierarchyTree responseOfGetHierarchy = new SPProviderHierarchyTree();
            try
            {
                responseOfGetHierarchy = this.cpswsClient.GetHierarchy(providerName, principalType, hierarchyNodeID, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [GetHierarchy] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyResponseData(responseOfGetHierarchy);

            return responseOfGetHierarchy;
        }
Esempio n. 27
0
        /// <summary>
        /// A method used to validate the GetHierarchy response. 
        /// </summary>
        /// <param name="getHierarchyResult">A parameter represents the GetHierarchy result.</param> 
        private void ValidateGetHierarchyResponseData(SPProviderHierarchyTree getHierarchyResult)
        {
            XmlElement xmlResponse = SchemaValidation.LastRawResponseXml;
            bool isResponseValid = SchemaValidation.ValidationResult == ValidationResult.Success;

            // The response have been received successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                192,
                @"[In GetHierarchy] The following is the WSDL port type specification of the GetHierarchy WSDL operation.
<wsdl:operation name=""GetHierarchy"" xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"">
  <wsdl:input wsaw:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/GetHierarchy"" message=""tns:IClaimProviderWebService_GetHierarchy_InputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
  <wsdl:output wsaw:Action=""http://schemas.microsoft.com/sharepoint/claims/IClaimProviderWebService/GetHierarchyResponse"" message=""tns:IClaimProviderWebService_GetHierarchy_OutputMessage"" xmlns:wsaw=""http://www.w3.org/2006/05/addressing/wsdl""/>
</wsdl:operation>");

            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                193,
                @"[In GetHierarchy] The protocol client sends an IClaimProviderWebService_GetHierarchy_InputMessage (section 3.1.4.4.1.1) request WSDL message and the protocol server responds with an IClaimProviderWebService_GetHierarchy_OutputMessage (section 3.1.4.4.1.2) response message.");

            // If the server response is validated successfully, and the GetHierarchyResponse has returned, MS-CPSWS_R202 can be verified.
            Site.CaptureRequirementIfIsTrue(
                this.ResponseExists(xmlResponse, "GetHierarchyResponse"),
                202,
                @"[In IClaimProviderWebService_GetHierarchy_OutputMessage] The [GetHierarchy] SOAP body contains the GetHierarchyResponse element.");

            // The response have been received successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResponseValid,
                213,
                @"[In GetHierarchyResponse] The GetHierarchyResponse element specifies the result data for the GetHierarchy WSDL operation.
<xs:element name=""GetHierarchyResponse"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:complexType>
    <xs:sequence>
      <xs:element minOccurs=""0"" maxOccurs=""1"" name=""GetHierarchyResult"" type=""tns:SPProviderHierarchyTree""/>
    </xs:sequence>
  </xs:complexType>
</xs:element>");

            if (getHierarchyResult != null)
            {
                this.VerifySPProviderHierarchyTreeComplexType(getHierarchyResult);
            }
        }