public async void DeleteUserProfile_UserAdmin() { var users = new List <UserProfile>() { new UserProfile { Id = "D3EF52BC-58FD-42EE-97E0-D110A0A9707A" }, new UserProfile { Id = "4F3743D9-214D-4CC4-BA71-204F34D17EAC" } }; var prevCount = users.Count; var store = new Mock <IUserRoleStore <UserProfile> >(); var userToDelete = users.Last(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(userToDelete); store.Setup(s => s.GetRolesAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(new List <string>() { "admin" }); store.Setup(s => s.DeleteAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(IdentityResult.Success).Callback(() => users.Remove(userToDelete)); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await administrationService.DeleteUserProfile(""); Assert.Equal(prevCount, users.Count); Assert.Contains(userToDelete, users); }
public void When_Creating_Home_Directory__Then_It_Should_Have_The_Appropriate_Rights() { var username = string.Format("testUser{0}", DateTime.Now.Millisecond); var administration = new AdministrationService(); var context = new PrincipalContext(ContextType.Machine); var user = new UserPrincipal(context) { Name = username, UserCannotChangePassword = false, PasswordNeverExpires = true, }; user.SetPassword("!Password123"); user.Save(); GroupPrincipal grp = GroupPrincipal.FindByIdentity(context, "IIS_IUSRS"); if (grp != null) { grp.Members.Add(user); grp.Save(); } Assert.IsNotNull(grp); string dir = Path.Combine(ConfigurationManager.AppSettings["HomeDirectory"], username); administration.MkDir(username, dir); bool exists = Directory.Exists(dir); Assert.IsTrue(exists); Directory.Delete(dir); user.Delete(); }
protected override async Task Save() { IList <string> errors = CheckRequiredFields(); if (errors.Count > 0) { await JavascriptFunctions.ShowAlert(errors[0]); } CustomerType customerType = null; if (IsNew()) { customerType = new CustomerType(); } else { customerType = await AdministrationService.GetCustomerType(Id.Value); } customerType.Text = this.Text; await AdministrationService.SaveCustomerType(customerType); UriHelper.NavigateTo("/Administration/CustomerType"); }
/// <summary> /// Handler for search event /// </summary> private void _Search() { List <Person> persons = AdministrationService.GetPersons(_View.Name, _View.Age, _View.Dept); //Setting contract for view to get information from presenter _View.Persons = persons; }
public BankModule(ClassicGuildBankClient client, CommandService commandService, ItemRequestService itemRequestService, AdministrationService administrationService) { _client = client; _commandService = commandService; _itemRequestService = itemRequestService; _administrationService = administrationService; }
public async void DeleteUserProfile_UserNotAdmin() { var users = new List <UserProfile>() { new UserProfile { Id = "6315DEBD-4EFB-47D9-80B4-B3C42DB72059" }, new UserProfile { Id = "FCB70CC5-D9E3-4396-B38E-1F9BB4DB2381" } }; var prevCount = users.Count; var store = new Mock <IUserRoleStore <UserProfile> >(); var userToDelete = users.Last(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(userToDelete); store.Setup(s => s.GetRolesAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(new List <string>() { "user" }); store.Setup(s => s.DeleteAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(IdentityResult.Success).Callback(() => users.Remove(userToDelete)); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await administrationService.DeleteUserProfile(""); Assert.NotEqual(prevCount, users.Count); Assert.DoesNotContain(userToDelete, users); }
public void When_Adding_Web_Site__Then_It_Should_Be_Able_To_Be_Deleted() { var simpleRandom = DateTime.Now.Millisecond; var username = string.Format("testUser{0}", simpleRandom); const string password = "******"; string fqdn = string.Format("www.testuser{0}.com", simpleRandom); var administrationService = new AdministrationService(); // Test to see if we could add a new user. var addUser = administrationService.AddUser(username, password, fqdn); Assert.IsTrue(addUser); // Test to see if we could reset permissions on home directory. var resetPermissions = administrationService.ResetPermissions(username); Assert.IsTrue(resetPermissions); // Test to see if we could add a new host on IIS. var addHost = administrationService.AddHost(username, fqdn); Assert.IsTrue(addHost); // Test to see if we could delete the newly created host from IIS. var delHost = administrationService.DelHost(username, fqdn); Assert.IsTrue(delHost); // Test to see if we could delete the newly created user from Windows. var delUser = administrationService.DelUser(username); Assert.IsTrue(delUser); }
public static AdministrationService getAdministrationService(String endPointAddress) { AdministrationService administrationService = new AdministrationService(); administrationService.Url = endPointAddress + ADMINISTRATION_SERVICE_ADDRESS; addSecurityHeader(administrationService); return(administrationService); }
protected async Task DeleteCustomerType(int customerTypeId) { await AdministrationService.DeleteCustomerType(customerTypeId); await JavascriptFunctions.ShowAlert("Suppression effectuée"); await LoadCustomerTypes(); }
private AdministrationService CreateAdministrationService() { //string userRole; var userID = Guid.Parse(User.Identity.GetUserId()); var service = new AdministrationService(userID); return(service); }
private static void AdministrationServiceBuildWithCars(out EfDeletableEntityRepository <Car> carRepository, out AdministrationService administrationService, out Car car, out Car car2, out string firstCarId) { DbContextOptionsBuilder <ApplicationDbContext> options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); carRepository = new EfDeletableEntityRepository <Car>(new ApplicationDbContext(options.Options)); var adServiceMock = new Mock <IAdService>(); administrationService = new AdministrationService(carRepository, adServiceMock.Object); car = new Car { Cc = 1, Color = Color.Chameleon, Condition = Condition.New, Door = Doors.Three, EuroStandart = EuroStandart.Euro1, Extras = "4x4", Fuel = Fuel.Diesel, Gearbox = Gearbox.Automatic, Horsepowers = 1, ImgsPaths = GlobalConstants.DefaultImgCar, Km = 100, Location = Location.Sofia, Make = Make.Audi, Model = "test", Modification = "test", MoreInformation = "test test", Price = 100, Type = Types.Convertible, TypeOfVeichle = TypeOfVeichle.Car, YearOfProduction = DateTime.ParseExact("01.1999", "mm.yyyy", CultureInfo.InvariantCulture), }; car2 = new Car { Cc = 1000, Color = Color.Black, Condition = Condition.New, Door = Doors.Three, EuroStandart = EuroStandart.Euro1, Extras = "4x4", Fuel = Fuel.Diesel, Gearbox = Gearbox.Automatic, Horsepowers = 1, ImgsPaths = GlobalConstants.DefaultImgCar, Km = 100, Location = Location.Sofia, Make = Make.Bmw, Model = "test2", Modification = "test2", MoreInformation = "test2 test2", Price = 100, Type = Types.Convertible, TypeOfVeichle = TypeOfVeichle.Car, YearOfProduction = DateTime.ParseExact("01.1999", "mm.yyyy", CultureInfo.InvariantCulture), }; firstCarId = car.Id; }
public async void UnbanUserProfile_UserNotFound() { var store = new Mock <IUserRoleStore <UserProfile> >(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(() => null); store.Setup(s => s.UpdateAsync(null, It.IsAny <CancellationToken>())).ThrowsAsync(new NullReferenceException()); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await Assert.ThrowsAsync(new NullReferenceException().GetType(), () => administrationService.UnbanUserProfile("")); }
/// <summary> /// InternalProcessRecord method override /// </summary> protected override void InternalProcessRecord() { SPFarm farm = SPFarm.Local; if (null == farm) { ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this); } AdministrationService service = farm.Services.GetValue <AdministrationService>(); if (null == service) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service not found."), ErrorCategory.ResourceUnavailable, this); } IdentityServiceApplication existingServiceApplication = service.Applications.GetValue <IdentityServiceApplication>(this.Name); if (null == existingServiceApplication) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service Application not found."), ErrorCategory.ResourceUnavailable, this); } if (this.ParameterSetName == AssemblyParameterSetName) { this.WriteObject(existingServiceApplication.GetAssemblyConfiguration()); } else if (this.ParameterSetName == ConfigurationParameterSetName) { this.WriteObject(existingServiceApplication.GetConnectionConfiguration(m_connection)); } else if (this.ParameterSetName == AllConfigurationParameterSetName) { this.WriteObject(existingServiceApplication.GetConnectionConfigurationList()); } else if (this.ParameterSetName == DomainParameterSetName) { this.WriteObject(existingServiceApplication.GetDomainConfiguration(m_domain)); } else if (this.ParameterSetName == AllDomainParameterSetName) { this.WriteObject(existingServiceApplication.GetDomainConfigurationList()); } else if (this.ParameterSetName == AllGlobalParameterSetName) { this.WriteObject(existingServiceApplication.FillGeneralParameters()); } else if (this.ParameterSetName == ReloadParameterSetName) { this.WriteObject(existingServiceApplication.Reload()); } else { throw new NotSupportedException("Parameter set not supported."); } }
// protected int CustomerTypeId { get; set; } #endregion #region Initialisation protected override async Task OnInitAsync() { this.Title = "Clients"; this.CustomerTypes = SelectListItems.Convert(await AdministrationService.GetCustomerTypes(), (src, dest) => { dest.Id = src.Id; dest.Text = src.Text; }); await LoadCustomers(); await JavascriptFunctions.InitTable("customerTable"); }
protected override async Task OnParametersSetAsync() { if (IsNew()) { this.Title = "Ajouter un type de client"; } else { this.Title = "Modifier un type de client"; CustomerType customerType = await AdministrationService.GetCustomerType(Id.Value); this.Text = customerType.Text; } }
public async void GetUserProfiles_UsersPagedListWrongParams() { var repo = new Mock <IRepository <UserProfile> >(); repo.Setup(r => r.GetAll(It.IsAny <UserProfileParams>())).ReturnsAsync(new PagedList <UserProfile>(AppUsers(), AppUsers().Count, 4, 11)); var service = new AdministrationService(repo.Object, null); var result = await service.GetUserProfiles(new UserProfileParams()); Assert.NotEmpty(result); Assert.Equal(AppUsers().Count, result.TotalCount); Assert.False(result.HasNext); Assert.True(result.HasPrevious); Assert.Equal(1, result.TotalPages); }
public void When_Adding_User__Then_It_Will_Be_Created_Under_IIS_IUSRS_Group() { var username = string.Format("testUser{0}",DateTime.Now.Millisecond); var administration = new AdministrationService(); administration.AddUser(username, "!Password123", "www.test.com"); var context = new PrincipalContext(ContextType.Machine); var grp = GroupPrincipal.FindByIdentity(context, "IIS_IUSRS"); Assert.IsNotNull(grp); var user = grp.Members.FirstOrDefault(x => x.Name == username); Assert.IsNotNull(user); user.Delete(); }
public async void UnbanUserProfile_UserFound() { var testUser = new UserProfile { IsBanned = true }; var store = new Mock <IUserRoleStore <UserProfile> >(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(testUser); store.Setup(s => s.UpdateAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(IdentityResult.Success).Callback(() => testUser.IsBanned = false); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await administrationService.UnbanUserProfile(""); Assert.False(testUser.IsBanned); }
/// <summary> /// InternalProcessRecord method override /// </summary> protected override void InternalProcessRecord() { SPFarm farm = SPFarm.Local; if (null == farm) { ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this); } AdministrationService service = farm.Services.GetValue <AdministrationService>(); if (null == service) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service not found."), ErrorCategory.ResourceUnavailable, this); } IdentityServiceApplication existingServiceApplication = service.Applications.GetValue <IdentityServiceApplication>(this.Name); if (null == existingServiceApplication) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service Application not found."), ErrorCategory.ResourceUnavailable, this); } if (this.ParameterSetName == AssemblyParameterSetName) { if (existingServiceApplication.SetAssemblyConfiguration(this.AssemblyConfiguration, this.NewAssemblyConfiguration)) { this.WriteObject("Assembly defintion correctly updated !"); } } else if (this.ParameterSetName == ConfigurationParameterSetName) { if (existingServiceApplication.SetConnectionConfiguration(this.ConnectionConfiguration, this.NewConnectionConfiguration)) { this.WriteObject("Connection parameters defintion correctly updated !"); } } else if (this.ParameterSetName == DomainParameterSetName) { if (existingServiceApplication.SetDomainConfiguration(this.DomainConfiguration, this.NewDomainConfiguration)) { this.WriteObject("Domain Configuration defintion correctly updated !"); } } else { throw new NotSupportedException("Parameter set not supported."); } }
public async void GetUserProfileInfo_UserFound() { var users = new List <UserProfile>() { new UserProfile { Id = "D809E7C3-4E25-4A07-9CCD-6823EF34FDEE" } }; var repo = new Mock <IRepository <UserProfile> >(); repo.Setup(r => r.GetById(Guid.Parse("D809E7C3-4E25-4A07-9CCD-6823EF34FDEE"))).ReturnsAsync(users.FirstOrDefault(u => u.Id.Equals("D809E7C3-4E25-4A07-9CCD-6823EF34FDEE"))); var service = new AdministrationService(repo.Object, null); var result = await service.GetUserProfileInfo("D809E7C3-4E25-4A07-9CCD-6823EF34FDEE"); Assert.NotNull(result); }
public async void GetUserProfileInfo_UserNotFound() { var users = new List <UserProfile>() { new UserProfile { Id = "AADA83F1-A63C-4F2A-AF22-DA7E5E57C6F6" } }; var repo = new Mock <IRepository <UserProfile> >(); repo.Setup(r => r.GetById(Guid.Parse("62EE5B40-DDBC-4C19-953A-D465A6294B98"))).ReturnsAsync(users.FirstOrDefault(u => u.Id.Equals("62EE5B40-DDBC-4C19-953A-D465A6294B98"))); var service = new AdministrationService(repo.Object, null); var result = await service.GetUserProfileInfo("62EE5B40-DDBC-4C19-953A-D465A6294B98"); Assert.Null(result); }
public void When_Deleting_User__Then_It_Should_Removed_And_Dissappear_From_IIS_IUSRS_Group() { var username = string.Format("testUser{0}", DateTime.Now.Millisecond); var administration = new AdministrationService(); var userAdded = administration.AddUser(username, "!Password123", ""); Assert.IsTrue(userAdded); var userDeleted = administration.DelUser(username); Assert.IsTrue(userDeleted); var context = new PrincipalContext(ContextType.Machine); UserPrincipal user = UserPrincipal.FindByIdentity(context, username); Assert.IsNull(user); var grp = GroupPrincipal.FindByIdentity(context, "IIS_IUSRS"); Assert.IsNotNull(grp); user = (UserPrincipal)grp.Members.FirstOrDefault(x => x.Name == username); Assert.IsNull(user); }
/// <summary> /// InternalProcessRecord method override /// </summary> protected override void InternalProcessRecord() { SPFarm farm = SPFarm.Local; if (null == farm) { ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this); } AdministrationService service = farm.Services.GetValue <AdministrationService>(); if (null == service) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service not found."), ErrorCategory.ResourceUnavailable, this); } IdentityServiceApplication existingServiceApplication = service.Applications.GetValue <IdentityServiceApplication>(this.Name); if (null == existingServiceApplication) { ThrowTerminatingError(new InvalidOperationException("SharePoint Identity Service Application not found."), ErrorCategory.ResourceUnavailable, this); } this.WriteObject(existingServiceApplication.Reload()); }
//------------------------------------------------------------------------------------------------------------------------- // Premier appel Radius public string AuthenticateRadius(string strUserName, string strPassword) { string messageLog = "== Authenticate Radius Step 1 ==============" + Environment.NewLine + "Radius Host : " + m_strRadiusHost + Environment.NewLine + "Radius Port : " + m_nRadiusPort + Environment.NewLine + "Shared Key : " + m_strRadiusSharedKey + Environment.NewLine + "Timos user name : " + strUserName + Environment.NewLine; string reponseRadius = "Request not sent"; if (strUserName != "youcef") { try { reponseRadius = AdministrationService.AuthenticateRadius(m_strRadiusHost, m_nRadiusPort, m_strRadiusSharedKey, strUserName, strPassword, ""); messageLog += "Radius response : " + reponseRadius + Environment.NewLine; } catch (Exception ex) { messageLog += "Radius response : " + ex.Message + Environment.NewLine; } Context.Log(InfoType.Information, messageLog); } else { messageLog += "Radius response : " + reponseRadius + Environment.NewLine; Context.Log(InfoType.Information, messageLog); return("11#blablabbal"); } return(reponseRadius); /* * if (ExecutingContext.CurrentHostUrl.ToLower().StartsWith(@"http://localhost")) * return "11#blablabbal"; * else * return AdministrationService.AuthenticateRadius(m_strRadiusHost, m_nRadiusPort, m_strRadiusSharedKey, strUserName, strPassword, ""); * //*/ }
public void When_Setting_NewPassword_On_User__Then_We_Should_Be_Able_To_Logon_With_New_Password() { var username = string.Format("testUser{0}", DateTime.Now.Millisecond); var administration = new AdministrationService(); var userAdded = administration.AddUser(username, "!Password123", ""); Assert.IsTrue(userAdded); var context = new PrincipalContext(ContextType.Machine); UserPrincipal user = UserPrincipal.FindByIdentity(context, username); Assert.IsNotNull(user); var validated = user.Context.ValidateCredentials(username, "!Password123"); Assert.IsTrue(validated); var passwdChanged = administration.SetPasswd(username, "!Password321"); Assert.IsTrue(passwdChanged); validated = user.Context.ValidateCredentials(username, "!Password321"); Assert.IsTrue(validated); var userDeleted = administration.DelUser(username); Assert.IsTrue(userDeleted); }
protected override async Task OnParametersSetAsync() { this.CustomerTypes = SelectListItems.Convert(await AdministrationService.GetCustomerTypes(), (src, dest) => { dest.Id = src.Id; dest.Text = src.Text; }); if (IsNew()) { this.Title = "Ajouter un client"; } else { this.Title = "Modifier un client"; Customer customer = await CustomerService.GetCustomer(Id.Value); this.Name = customer.Name; this.FirstName = customer.FirstName; this.CustomerTypeId = customer.CustomerTypeId; } }
protected void MailEm(object state) { try { object[] array = state as object[]; SessionHelper h = (SessionHelper)array[0]; string tamplate = (string)array[1]; string vals = (string)array[2]; AdministrationService administrationService = new AdministrationService(new AdministrationRepository(), h); MailEmployeeRecordRequest req = new MailEmployeeRecordRequest(); req.param = vals; req.templateId = tamplate; RecordResponse <MailEmployee> resp = administrationService.ChildGetRecord <MailEmployee>(req); if (!resp.Success) { HttpRuntime.Cache.Insert("ErrorMsgGenEM", resp.Summary); HttpRuntime.Cache.Insert("ErrorLogIdGenEM", resp.LogId); HttpRuntime.Cache.Insert("ErrorErrorCodeGenEM", resp.ErrorCode); } else { if (!string.IsNullOrEmpty(resp.recordId)) { HttpRuntime.Cache.Insert("genEM_RecordId", resp.recordId); } } } catch (Exception exp) { X.Msg.Alert(Resources.Common.Error, exp.Message).Show(); } }
public AdminModule(AdministrationService administrationService) { _administrationService = administrationService; }
public AdministrationController() { _userService = new UserService(Data); _storeService = new StoreService(Data); _adminService = new AdministrationService(Data); }
public void RemoveArticle(int articleId) { AdministrationService.RemoveArticle(articleId); }
public void RemoveComment(int commentId) { AdministrationService.RemoveComment(commentId); }
public AdministrationController(AdministrationService administrationService) { _administrationService = administrationService; }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> /// public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { var dbContext = new Model1(); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); StateClient sc = activity.GetStateClient(); BotData userData = sc.BotState.GetPrivateConversationData(activity.ChannelId, activity.Conversation.Id, activity.From.Id); var userSelectedLanguage = userData.GetProperty <string>("Language"); var userSelectedCity = userData.GetProperty <string>("City"); var guid = userData.GetProperty <string>("ApartmantId"); if (string.IsNullOrEmpty(userSelectedLanguage)) { await Conversation.SendAsync(activity, MakeRootDialog); } else if (activity.Text == "/deleteprofile") { activity.GetStateClient().BotState.DeleteStateForUser(activity.ChannelId, activity.From.Id); } else { var userCity = userData.GetProperty <string>("City"); var userAddress = userData.GetProperty <string>("Address"); var googleApi = new GoogleTranslateService(); var location = googleApi.GetLocationFromAddress(userAddress + "," + userCity); var administrationService = new AdministrationService(); var possibleLocations = administrationService.GetPossibleLocations(location); if (possibleLocations.FirstOrDefault(x => x.ApartmentId.ToString() == activity.Text) == null && string.IsNullOrEmpty(guid)) { if (possibleLocations.Count > 0) { userData.SetProperty <string>("ApartmantId", "IdComming"); sc.BotState.SetPrivateConversationData(activity.ChannelId, activity.Conversation.Id, activity.From.Id, userData); Activity replyToConversation = activity.CreateReply(GetTextInSelectedLanguage("Please select your place", userSelectedLanguage)); replyToConversation.Recipient = activity.From; replyToConversation.Type = "message"; replyToConversation.Attachments = new List <Attachment>(); List <CardAction> cardButtons = new List <CardAction>(); foreach (var button in possibleLocations) { CardAction plButton = new CardAction() { Value = button.ApartmentId.ToString(), Type = "imBack", Title = button.Name }; cardButtons.Add(plButton); } HeroCard plCard = new HeroCard() { Title = GetTextInSelectedLanguage("Press the button with your accomodation", userSelectedLanguage), Buttons = cardButtons }; Attachment plAttachment = plCard.ToAttachment(); replyToConversation.Attachments.Add(plAttachment); await connector.Conversations.SendToConversationAsync(replyToConversation); await sc.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); } else { var responseText = GetTextInSelectedLanguage("Sorry, havn't found anything. Try again", userSelectedLanguage); Activity replyToSelectedApartmen = activity.CreateReply($"{responseText}"); await connector.Conversations.ReplyToActivityAsync(replyToSelectedApartmen); } } else if (guid == "IdComming") { userData.SetProperty <string>("ApartmantId", activity.Text); guid = activity.Text; sc.BotState.SetPrivateConversationData(activity.ChannelId, activity.Conversation.Id, activity.From.Id, userData); // await sc.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); var responseText = GetTextInSelectedLanguage("Go ahed and ask me something", userSelectedLanguage); Activity replyToSelectedApartmen = activity.CreateReply($"{responseText}"); await connector.Conversations.ReplyToActivityAsync(replyToSelectedApartmen); } else { var tokenizedText = googleApi.SentanceDetect(GetTextInEng(activity.Text, userSelectedLanguage)); var resText = administrationService.GetResponeseToQuery(tokenizedText, guid); if (resText != null) { Activity reply = activity.CreateReply($"{resText.Answer}"); await connector.Conversations.ReplyToActivityAsync(reply); } else { var responseText = GetTextInSelectedLanguage("Sorry, have not found anything. Try again", userSelectedLanguage); Activity reply = activity.CreateReply($"{responseText}"); await connector.Conversations.ReplyToActivityAsync(reply); } } } } else { HandleSystemMessage(activity); } return(new HttpResponseMessage()); }
public void RemoveQuestion(int questionId) { AdministrationService.RemoveQuestion(questionId); }
public void When_Creating_New_Site__It_Should_Be_Present_In_IIS() { var username = string.Format("testUser{0}", DateTime.Now.Millisecond); const string password = "******"; var administration = new AdministrationService(); var context = new PrincipalContext(ContextType.Machine); var user = new UserPrincipal(context) { Name = username, UserCannotChangePassword = false, PasswordNeverExpires = true, }; user.SetPassword(password); user.Save(); var grp = GroupPrincipal.FindByIdentity(context, "IIS_IUSRS"); if (grp != null) { grp.Members.Add(user); grp.Save(); } Assert.IsNotNull(grp); var dir = Path.Combine(ConfigurationManager.AppSettings["HomeDirectory"], username); var info = Directory.CreateDirectory(dir); var security = info.GetAccessControl(); security.AddAccessRule(new FileSystemAccessRule(username, FileSystemRights.Read | FileSystemRights.Write | FileSystemRights.Modify | FileSystemRights.CreateDirectories | FileSystemRights.CreateFiles | FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)); info.SetAccessControl(security); var server = new IisServer(); // In order to make this work, you will have to add an entry to your host file or dns... const string fqdn = "www.test.com"; server.AddWebSite(username, password, fqdn, dir, "http", string.Format("*:80:{0}", fqdn)); using (var serverManager = new ServerManager()) { var site = serverManager.Sites.FirstOrDefault(x => x.Name == fqdn); Assert.IsNotNull(site); var app = site.Applications.FirstOrDefault(); Assert.IsNotNull(app); var pool = serverManager.ApplicationPools.FirstOrDefault(x => x.Name == fqdn); Assert.IsNotNull(pool); // Cleaning up... app.Delete(); site.Delete(); pool.Delete(); serverManager.CommitChanges(); } // Cleaning up... Directory.Delete(dir, true); user.Delete(); }
//------------------------------------------------------------------------------------------------------------------------- // Authenticate user, using Security Service Configuration AspectizeUser IAuthentication.Authenticate(string userName, string secret, AuthenticationProtocol protocol, HashHelper.Algorithm algorithm, string challenge) { var parts = secret.Split('#'); string otp = parts[0]; //string password = string.Join("#", parts, 1, parts.Length - 1); string password = parts[1]; string state = parts[2]; string messageLog = "== Authenticate Radius Step 2 ==============" + Environment.NewLine + "Timos user name : " + userName + Environment.NewLine + "Radius Host : " + m_strRadiusHost + Environment.NewLine + "Radius Port : " + m_nRadiusPort + Environment.NewLine + "Shared Key : " + m_strRadiusSharedKey + Environment.NewLine + "OTP : " + otp + Environment.NewLine + "STATE : " + state + Environment.NewLine; string reponseRadius = "Request not sent"; if (userName != "youcef") { try { reponseRadius = AdministrationService.AuthenticateRadius(m_strRadiusHost, m_nRadiusPort, m_strRadiusSharedKey, userName, otp, state); messageLog += "Radius response : " + reponseRadius + Environment.NewLine; } catch (Exception ex) { messageLog += "Radius response : " + ex.Message + Environment.NewLine; } Context.Log(InfoType.Information, messageLog); var parts2 = reponseRadius.Split('#'); if (parts2[0] != "2") { return(AspectizeUser.GetUnAuthenticatedUser()); // L'authentification OTP a échoué } } else { messageLog += "Radius response : " + reponseRadius + Environment.NewLine; Context.Log(InfoType.Information, messageLog); } // Authentification TIMOS ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.OpenSession(userName, password); if (result && result.Data is Dictionary <string, object> ) { string strUserKey = ""; // Build Key-Value attached to User Dictionary <string, object> dicoProperties = (Dictionary <string, object>)result.Data; strUserKey = (string)dicoProperties[CUserTimosWebApp.c_champUserKey]; // Build Role List List <string> roles = new List <string>(); roles.Add("Registered"); // Build and return authenticated user with Properties and Roles return(AspectizeUser.GetAuthenticatedUser(strUserKey, roles.ToArray(), dicoProperties)); } return(AspectizeUser.GetUnAuthenticatedUser()); // Fin authentification TIMOS }