public Task <IEnumerable <FabricGroup> > SearchGroupsAsync( string searchText, string searchType, string tenantId = null) { var fabricGroups = new List <FabricGroup>(); switch (searchType) { case FabricIdentityConstants.SearchTypes.Wildcard: _activeDirectoryQuery = new ActiveDirectoryWildcardQuery(); break; case FabricIdentityConstants.SearchTypes.Exact: _activeDirectoryQuery = new ActiveDirectoryExactMatchQuery(); break; default: throw new Exception($"{searchType} is not a valid search type"); } var ldapQuery = _activeDirectoryQuery.QueryText(searchText, FabricIdentityEnums.PrincipalType.Group); var searchResults = _activeDirectoryProxy.SearchDirectory(ldapQuery); foreach (var searchResult in searchResults) { if (!IsDirectoryEntryAUser(searchResult)) { fabricGroups.Add(CreateFabricGroup(searchResult)); } } return(Task.FromResult(fabricGroups.AsEnumerable())); }
public UserController(IUserPermissionService userSvc, IUserHelper oldUser, IActiveDirectoryQuery adQuery, IQueueService queueService) { _userSvc = userSvc; _oldUser = oldUser; _adQuery = adQuery; _queueService = queueService; }
public async Task <IEnumerable <FabricPrincipal> > SearchPrincipalsAsync( string searchText, FabricIdentityEnums.PrincipalType principalType, string searchType, string tenantId = null) { switch (searchType) { case FabricIdentityConstants.SearchTypes.Wildcard: _activeDirectoryQuery = new ActiveDirectoryWildcardQuery(); break; case FabricIdentityConstants.SearchTypes.Exact: _activeDirectoryQuery = new ActiveDirectoryExactMatchQuery(); break; default: throw new Exception($"{searchType} is not a valid search type"); } var ldapQuery = _activeDirectoryQuery.QueryText(searchText, principalType); var principals = await Task.Run(() => FindPrincipalsWithDirectorySearcher(ldapQuery)).ConfigureAwait(false); return(principals); }