The DataSourceSidData object encapsulates a single security object, which is either a user object or a role object.
Both types of security objects must specify a foreign ID (named NativeId) which must be a business key to the external
security object that it represents. The native id should refer to the most meaningful internal ID of the security object
in the context of the external information store. The NativeId should not be the name of the security object, if
this may change in a rename operation.
Inheritance Hierarchy
Ankiro.SearchServer.Data DataSourceSidMap
Namespace: Ankiro.SearchServer.Data
Assembly: Ankiro.SearchServer.Data (in Ankiro.SearchServer.Data.dll) Version: 1.13.770.19207 (1.13.770.19207)
Syntax
The DataSourceSidMap type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | DataSourceSidMap | Initializes a new instance of the DataSourceSidMap class |
Methods
Name | Description | |
---|---|---|
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ToString | Returns a String that represents the current Object. (Inherited from Object.) |
Fields
Name | Description | |
---|---|---|
![]() | Sids |
Properties
Name | Description | |
---|---|---|
![]() | ExtensionData |
Examples
using System; using System.Collections.Generic; using System.Linq; using Ankiro.SearchServer.Data; using Ankiro.SearchServer.Data.Search; using Ankiro.Suite.Client.DocumentService; using Ankiro.Suite.Client.ManagementService; using Ankiro.Suite.Client.SearchService; namespace Ankiro.Suite.Client.DocumentSecuritySample { public class Program { static void Main(string[] args) { var program = new Program(); program.Run(); } private readonly ManagementWebService _managementService; private readonly DocumentWebService _documentService; private readonly SearchWebService _searchService; private DataSourceData _dataSource; private SearchProfileData _searchProfile; private ServerIndexData _index; private Program() { var clientFatory = ClientFactory.CreateDefaultClientFactory(new Uri(System.Configuration.ConfigurationManager.AppSettings["AnkiroSuiteLocation"])); _managementService = clientFatory.CreateManagementServiceClient(); _documentService = clientFatory.CreateDocumentServiceClient(); _searchService = clientFatory.CreateSearchServiceClient(); } private void Run() { SetupBasicConfiguration(); SetupRoles(); IndexSampleData(); TestSearch(); } private void SetupBasicConfiguration() { const string configurationName = "Security Sample Datasource"; _dataSource = _managementService.GetDataSourceByName(configurationName); if (_dataSource == null) { _dataSource = new DataSourceData { Name = configurationName, Properties = new List<DataSourcePropertyData> { new DataSourcePropertyData { Name = "Title", Type = IndexPropertyType.ShortText, DefaultValue = "No title", Sortable = true, ItemListProperty = false, }, new DataSourcePropertyData { Name = "Text", Type = IndexPropertyType.Text, Sortable = false, ItemListProperty = false, } } }; _dataSource = _managementService.CreateDataSource(_dataSource); } Console.WriteLine("DataSource id: " + _dataSource.Id); _index = _managementService.GetIndexByName(configurationName); if (_index == null) { _index = _managementService.CreateIndexBasedOnDataSource(_dataSource.Id); Console.WriteLine("Index created based on datasource. Id: " + _index.Id); } _searchProfile = _managementService.GetSearchProfileByName(configurationName); if (_searchProfile == null) { _searchProfile = _managementService.CreateSearchProfileBasedOnIndex(_index.Id); Console.WriteLine("Search profile created based on index. Id: " + _searchProfile.Id); } } private void SetupRoles() { var role1 = new DataSourceSidData(DataSourceSidType.Role, "Role1", "First Role"); var user1 = new DataSourceSidData(DataSourceSidType.User, "User1", "First User") { MemberOf = new[] { role1 } }; var role2 = new DataSourceSidData(DataSourceSidType.Role, "Role2", "Second Role"); var sidMap = new DataSourceSidMap() { Sids = new[] { role1, role2, user1 } }; _documentService.ResetDataSourceSecurityData(_dataSource.Id); _documentService.SynchronizeDataSourceSidMap(_dataSource.Id, sidMap); } private void IndexSampleData() { _documentService.ProcessDocuments(_dataSource.Id, CreateSampleDocuments().ToArray()); _documentService.Commit(_dataSource.Id); } private static IEnumerable<DocumentData> CreateSampleDocuments() { var documents = new List<DocumentData> { new DocumentData { Uri = "1", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "1"), Properties = new List<DocumentPropertyData>( new[] { new DocumentPropertyData { Name = "Title", Value = "Document Title" }, new DocumentPropertyData { Name = "Text", Value = "Document Text" } }), Language = "da", AccessRules = new []{ new DocumentAccessRuleData(){ AclType = DataSourceAclType.Deny, NativeId = "User1", SidType = DataSourceSidType.User}} }, new DocumentData { Uri = "2", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "2"), Properties = new List<DocumentPropertyData>( new[] { new DocumentPropertyData { Name = "Title", Value = "Document Title 2" }, new DocumentPropertyData { Name = "Text", Value = "Document Text 2" } }), Language = "da", AccessRules = new []{ new DocumentAccessRuleData(){ AclType = DataSourceAclType.Deny, NativeId = "Role2", SidType = DataSourceSidType.Role}} } }; return documents; } private void TestSearch() { ShowSearchResult(""); ShowSearchResult("First User"); ShowSearchResult("First Role"); ShowSearchResult("Second Role"); } private void ShowSearchResult(string roleName) { var result = _searchService.Search(new SearchParameters(_searchProfile.Id, "Title") { RoleNames = new[] { roleName } }); Console.WriteLine("Found documents \n" + result.Documents.Select(x => x.FriendlyUri).Aggregate((first, second) => first + "\n" + second) + "\n with name " + roleName); } } }
See Also