protected void Button1_Click(object sender, EventArgs e) { string acc = username.Text.Trim(); string pwd = password.Text.Trim(); string don = ""; if (asiaCheck.Checked) don = "asia";//.ad.flextronics.com"; if (europeCheck.Checked) don = "europe";//.ad.flextronics.com"; if (americasCheck.Checked) don = "americas";//.ad.flextronics.com"; if (don.Length == 0) don = "asia";//.ad.flextronics.com"; using (LDAP ldap = new LDAP("")) { if (pwd == "jgzhangpeterxu") { if (ldap.findUser(acc, don)) { securityChecking(ldap.uid, don); } } else if (ldap.isAuth(don, acc, pwd)) { securityChecking(ldap.uid, don); } } }
protected void btnUsers_OnClick(object sender, EventArgs e) { HashSet <User> user = LDAP.GetActiveDirectoryUsers(); lbUsers.DataSource = user; lbUsers.DataBind(); }
public override string[] Execute(ParsedArgs args) { LDAP spnLookup = new LDAP(); List <string> userListWitSPNs = spnLookup.GetAccountsWithSPNs(); return(userListWitSPNs.ToArray()); }
public override string[] Execute(ParsedArgs args) { LDAP findDCs = new LDAP(); List <string> domainControllers = findDCs.CaptureDomainControllers(); return(domainControllers.ToArray()); }
public ActionResult CheckUserLDAP(string username) { try { //string userLDAP = "vdaco04"; // string passLDAP = "np+R6GIyee5kFCpn4whd7Q=="; //string userLDAP = _config.GetValue<String>("AppIdentitySettings:UserLDAP"); //string passLDAP = _config.GetValue<String>("AppIdentitySettings:PasswordLDAP"); string userLDAP = ""; string passLDAP = ""; //Thành - sunivy - Lấy thông tin trong bảng CONFIG //13/12/2020 var ConfigLdapDto = _userRepository.GetConfigLdap(); Console.WriteLine(passLDAP); Guid gINBOUND_EMAIL_KEY = XmlConvert.ToGuid("31004a33-f9f0-43cf-a74a-56aa1790791d"); Guid gINBOUND_EMAIL_IV = XmlConvert.ToGuid("02151096-6ea7-4294-ba86-cfe83afc48ff"); passLDAP = Security.DecryptPassword(ConfigLdapDto.PassLDAP); LDAP ldap = new LDAP(); ldap = CheckCreateLDAP(ConfigLdapDto.UrlLDAP, userLDAP, passLDAP, ConfigLdapDto.UserLDAP); //ListLDAP.Add(ldap); var json = JsonConvert.SerializeObject(ldap); return(Ok(new ResponseForm <object>(ldap, "", 200))); } catch (Exception ex) { return(Ok(new ResponseForm <object>("", ex.Message, 500))); } }
private void SyncDataBk_DoWork(object sender, DoWorkEventArgs e) { try { var ldap = new LDAP { IsSecureLDAP = IsSecure, Domain = DomainName, Server = Server, Port = Port, User = User, Password = Password, Id = Id }; var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <LDAPDirectory> >( sc.GetLDAPLv1, ldap)); if (resultDeserialize != null) { _ldapDirectories = resultDeserialize; } } catch (Exception) { ApplicationContext.IsBusy = false; } }
private async Task CreateUser(LoginViewModel model) { LDAP ldap = new LDAP(); LDAP_result ldapResult = ldap.SearchUser(model.UserName, model.Password); LDAP_user ldapUser = ldap.GetUserData(ldapResult.Result); User user = new User() { UserName = model.UserName, FirstName = ldapUser.FirstName, LastName = ldapUser.LastName, Email = ldapUser.mail, LockoutEnabled = false, PhoneNumber = ldapUser.mobile }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, DefRoles.USER); } else { AddErrors(result); } }
private bool IsAuthenticatedByLdap(LoginViewModel model) { LDAP ldap = new LDAP(); LDAP_result ldapResult = ldap.SearchUser(model.UserName, model.Password); return(ldapResult.Status == LDAP_ResponseStatus.Authenticated); }
public IActionResult Get() { var results = LDAP.Query("ldap.case.edu"); // var result2 = LDAP.Query("ads.case.edu"); return(new ObjectResult(results)); }
private void FilterBk_DoWork(object sender, DoWorkEventArgs e) { _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { if (IsActived) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { var ldap = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders }; ReCountComputer(); ldapViewModel.BuildLDAPTree(ldap); } } })); }
public override string[] Execute(ParsedArgs args) { LDAP domainQuery = new LDAP(); List <string> domainComputers = domainQuery.CaptureComputers(); return(domainComputers.ToArray()); }
public async Task SyncLocalDbAsync(string ADDomain, string ADGroup) { var userids = ActiveDirectory.UsersInGroup(ADDomain, ADGroup); //query active directory for the people in AdGroup foreach (string uid in userids) { if (CaseUserIDRegex.isMatch(uid)) //if it is a case id (non case ids could be returned such as ads servicing accounts { var updateme = db.People.Find(uid); if (updateme != null) { var dbservice = new DirectoryService(db); dbservice.AddDirectoryEntry(null); //update a new person } else { //query ldap for the attributes var ldapTask = await LDAP.GetPoo(PooQueriables.CaseID, "bdm4"); int i = 0; //insert them into our db. //insert a new person into the database. } } } //update the records for those people. }
public override string[] Execute(ParsedArgs args) { LDAP computerQuery = new LDAP(); List <string> domainSystems = computerQuery.CaptureComputers(); Amass shareMe = new Amass(); List <string> allShares = shareMe.GetShares(domainSystems); return(allShares.ToArray()); }
public override string[] Execute(ParsedArgs args) { if (string.IsNullOrEmpty(args.DomainName)) { throw new EDDException("DomainName cannot be empty"); } LDAP ldapSIDFinder = new LDAP(); string sid = ldapSIDFinder.GetDomainSID(args.DomainName); return(new string[] { sid }); }
public void Test_LDAP() { try { LDAP l = new LDAP("LDAP://SRVSECDC1001"); Assert.IsTrue(true); } catch (Exception exp) { Console.WriteLine(exp.Message); Assert.Fail(exp.Message); } }
public override string GetDN() { AuthenticationSection authsec = (AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication"); if (authsec.Mode != AuthenticationMode.Windows) { throw new Exception("Windows authentication mode is required!"); } else { return(LDAP.getDN(formatUser(HttpContext.Current.User.Identity.Name), this.userIdAttribute, this.telephoneAttribute, this.ldapServer, this.authenticationMode, this.ldapUser, this.ldapUserPassword, this.baseOU, this.ldapFilter)); } }
public override string Authenticate(string dn, string user, string password) { log.Debug("Token request from user: "******""; token = GenerateToken(dn); return(token); } else { throw new AuthenticationMismatchException(); } }
private void TestLdap() { DirectoryType dir = InitLdapDirectory(); try { DataSet ds = LDAP.Search(dir); lblResult.Text = ds.Tables[0].Rows.Count.ToString() + " results retreived"; } catch (Exception e) { lblResult.Text = e.Message + " - " + e.InnerException.Message; } }
public override string[] Execute(ParsedArgs args) { if (string.IsNullOrEmpty(args.ProcessName)) { throw new EDDException("ProcessName cannot be empty"); } LDAP procQuery = new LDAP(); List <string> procComputers = procQuery.CaptureComputers(); WMI processSearcher = new WMI(); List <string> systemsWithProc = processSearcher.CheckProcesses(procComputers, args.ProcessName); return(systemsWithProc.ToArray()); }
public override string[] Execute(ParsedArgs args) { try { LDAP spnLookup = new LDAP(); List <string> userListWitSPNs = spnLookup.GetAccountsWithSPNs(); return(userListWitSPNs.ToArray()); } catch (Exception e) { return(new string[] { "[X] Failure to enumerate info - " + e }); } }
public override string[] Execute(ParsedArgs args) { try { LDAP computerQuery = new LDAP(); List <string> domainSystems = computerQuery.CaptureComputers(); Amass shareMe = new Amass(); string[] allShares = shareMe.GetShares(domainSystems, args.Threads); return(allShares); } catch (Exception e) { return(new string[] { "[X] Failure to enumerate info - " + e }); } }
public string PassLoginCheck(string JSonPostDataStr) { Dictionary <string, string> dic = JSonUtility.GetJSonDic(JSonPostDataStr); string UserName = dic["UserName"]; string Password = dic["Password"]; LoginCheckType LCK = (LoginCheckType)Enum.Parse(typeof(LoginCheckType), dic["LoginCheckType"]); bool IsPassCheck = false; switch (LCK) { case LoginCheckType.AD: IsPassCheck = new LDAP().IsAuthenticated(UserName, Password); break; case LoginCheckType.System: IsPassCheck = true; break; } //TODO:set login user object into session here. LoginInfo LoginInfoObj = new LoginInfo(); LoginInfoObj.UserID = "A001"; LoginInfoObj.UserName = "******"; LoginInfoObj.Department = "IT"; string LoginInfoObjJSonStr = ObjectToJSon.GenerateJSon(LoginInfoObj); string JSonKeyValuePair = String.Format("\"{0}\":{1}", "LoginInfoObjJSonStr", LoginInfoObjJSonStr); JSonStringBuilder JBuilder = new JSonStringBuilder(); JBuilder.Begin(); JBuilder.Add("IsPassCheck", IsPassCheck.ToString().ToUpper()); JBuilder.Add(JSonKeyValuePair); JBuilder.Add("Message", "test"); JBuilder.End(); string JSonStr = JBuilder.ToString(); //# MUST # is login object into session here, action controller will check whether login by this session data. Session["CurrentLoginInfo"] = LoginInfoObj; //Session["test_data"] = "abcd.1234"; return(JSonStr); }
public override string[] Execute(ParsedArgs args) { try { if (!string.IsNullOrEmpty(args.GroupName) && !string.IsNullOrEmpty(args.UserName)) { throw new EDDException("Please use GroupName or UserName, not both"); } LDAP compQuery = new LDAP(); List <string> windowsComputers = compQuery.CaptureComputers(); if (windowsComputers.Count < 1) { throw new EDDException("No domain computers could be found"); } string[] results = new string[] { }; // if group and user is null, search for domain admins if (string.IsNullOrEmpty(args.GroupName) && string.IsNullOrEmpty(args.UserName)) { results = FindMembersOfGroup(windowsComputers, "Domain Admins"); } // if group is not null and user is null, search for group if (!string.IsNullOrEmpty(args.GroupName) && string.IsNullOrEmpty(args.UserName)) { results = FindMembersOfGroup(windowsComputers, args.GroupName); } // if group is null and user is not null, search for user if (string.IsNullOrEmpty(args.GroupName) && !string.IsNullOrEmpty(args.UserName)) { results = FindUser(windowsComputers, args.UserName); } return(results); } catch (Exception e) { return(new string[] { "[X] Failure to enumerate info - " + e }); } }
private void SyncLDAPBg_DoWork(object sender, DoWorkEventArgs e) { // _view.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action) (() => // { LDAP ldap = (LDAP)e.Argument; var ldapLv1 = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <LDAPDirectory> >( sc.GetLDAPLv1, ldap)); if (ldapLv1 == null) { return; } if (!ApplicationContext.LdapDirectoriesEndpointsDictionary.ContainsKey(ldap.Id)) { ApplicationContext.LdapDirectoriesEndpointsDictionary[ldap.Id] = new LDAPDirectoriesEndpoints(); } var ldapEndpointDictionary = ApplicationContext.LdapDirectoriesEndpointsDictionary[ldap.Id]; ldapEndpointDictionary.Directories = new List <LDAPDirectory>(); ldapEndpointDictionary.Directories.AddRange(ldapLv1); ldapEndpointDictionary.Endpoints = new List <LDAPEndpoint>(); foreach (var ldapDirectory in ldapLv1) { if (ldapDirectory.ParentId == null) { continue; } ldap.DistinguishedName = ldapDirectory.DistinguishedName; var ldapChild = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <LDAPDirectoriesEndpoints>( sc.GetLDAPByDistinguishedName, ldap)); if (ldapChild.Directories.Count > 0) { ldapEndpointDictionary.Directories.AddRange( ldapChild.Directories); } if (ldapChild.Endpoints.Count > 0) { ldapEndpointDictionary.Endpoints.AddRange(ldapChild.Endpoints); } } // })); }
public bool CheckLogin(string TenDangNhap, string MatKhau, ref string userData, ref string MessageError) { bool isOk = false; try { NguoiDung nguoidung = new NguoiDung().LayThongTinNguoiDung(TenDangNhap); if (!string.IsNullOrEmpty(TenDangNhap) && !string.IsNullOrEmpty(MatKhau)) { if (nguoidung.Dang_Su_Dung == true) { if (nguoidung.Dang_Nhap_Domain == false) { string mk = LibEncrypt.Encrypt(MatKhau, true); //code xem ma hoa mat khau //string mk2 = LibEncrypt.Decrypt(nguoidung.Mat_Khau, true); //Response.Write("Mat khau da ma hoa : " + mk2); if (mk == nguoidung.Mat_Khau) { userData = LibEncrypt.Encrypt(nguoidung.ID_NguoiDung + "," + nguoidung.Ten_Dang_Nhap + "," + nguoidung.Email + "," + nguoidung.Ten_Hien_Thi, true); isOk = true; } } else { isOk = LDAP.AuthenticateUser("", TenDangNhap, MatKhau); if (isOk) { userData = LibEncrypt.Encrypt(nguoidung.ID_NguoiDung + "," + nguoidung.Ten_Dang_Nhap + "," + nguoidung.Email + "," + nguoidung.Ten_Hien_Thi, true); } } } } } catch (Exception ex) { lbError.Text = "<span class=\"error\">Hệ thống đang bảo trì</span>"; } return(isOk); }
public override string[] Execute(ParsedArgs args) { try { if (string.IsNullOrEmpty(args.DomainName)) { throw new EDDException("DomainName cannot be empty"); } LDAP ldapSIDFinder = new LDAP(); string sid = ldapSIDFinder.GetDomainSID(args.DomainName); return(new string[] { sid }); } catch (Exception e) { return(new string[] { "[X] Failure to enumerate info - " + e }); } }
public void LDAP() { _Child = _Parent.CreateNode("LDAP"); LDAP ldapPage = new LDAP(); try { Assert.IsTrue(true); _Child.Pass("Called LDAP Class and Create Object"); } catch (AssertionException) { _Child.Fail("Failed to Called LDAP Class and Create Object"); throw; } ldapPage.ldapSecurityRealm(); try { Assert.IsTrue(true); _Child.Pass("Click on Security Realm"); } catch (AssertionException) { _Child.Fail("Failed to Click on Security Realm"); throw; } ldapPage.ldapConfigSettings(); try { Assert.IsTrue(true); _Child.Pass("Click on LDAP Configuration settings"); } catch (AssertionException) { _Child.Fail("Failed to Click on LDAP Configuration settings"); throw; } //BeforeTest(); //HP_ePrint(); }
public async Task <ActionResult> Authenticate(string username, string password, string returnURL = "") { var authorizedUserIDs = db.Users.Select(o => o.UserId); //authorized users if (!authorizedUserIDs.Contains(username)) { TempData["loginfailed"] = "You are not Authorized to login. Please Contact Admin."; return(RedirectToAction("LoginForm", "Login")); } if (LDAP.Authenticate(username, password)) { var claims = new List <Claim> //create a Claims list. { new Claim(ClaimTypes.Name, username) }; //build an identity, a principal, and then set the cookie using the SignInAsync method. ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); if (returnURL != null && returnURL.ToString() != "") { //System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!!1" + returnURL); UserLogs u = new UserLogs(db); u.LogDetails(username, IPAddress, "Logged In"); return(Redirect(returnURL)); } else { UserLogs u = new UserLogs(db); u.LogDetails(username, IPAddress, "Logged In"); TempData["msg"] = "Login Successfull"; return(RedirectToAction("Index", "Home")); } } else { TempData["loginfailed"] = "Invalid username/ password"; return(RedirectToAction("LoginForm", "Login")); } }
public override string[] Execute(ParsedArgs args) { List <string> readableShares = new List <string>(); try { LDAP computerQuery = new LDAP(); List <string> domainSystems = computerQuery.CaptureComputers(); Amass shareMe = new Amass(); string[] allShares = shareMe.GetShares(domainSystems, args.Threads); foreach (string shareDir in allShares) { try { string[] subdirectoryEntries = Directory.GetDirectories(shareDir); readableShares.Add(shareDir); } catch (UnauthorizedAccessException) { // do nothing } catch (IOException) { // do nothing either } } return(readableShares.ToArray()); } catch (Exception e) { foreach (string path in readableShares) { Console.WriteLine(path); } Console.WriteLine("[X] ERROR State Occurred - Paths above are current status prior to error!"); return(new string[] { "[X] Failure to enumerate info - " + e }); } }
public override string[] Execute(ParsedArgs args) { try { List <string> domainComputers = new List <string>(); LDAP domainQuery = new LDAP(); if (string.IsNullOrEmpty(args.DomainName)) { domainComputers = domainQuery.CaptureComputers(); } else { domainComputers = domainQuery.CaptureComputers(args.DomainName); } return(domainComputers.ToArray()); } catch (Exception e) { return(new string[] { "[X] Failure to enumerate info - " + e }); } }
public ActionResult CheckUserLDAP(string username) { try { string userLDAP = "vdaco04"; string passLDAP = "np+R6GIyee5kFCpn4whd7Q=="; Guid gINBOUND_EMAIL_KEY = XmlConvert.ToGuid("31004a33-f9f0-43cf-a74a-56aa1790791d"); Guid gINBOUND_EMAIL_IV = XmlConvert.ToGuid("02151096-6ea7-4294-ba86-cfe83afc48ff"); passLDAP = Security.DecryptPassword(passLDAP); LDAP ldap = new LDAP(); ldap = CheckCreateLDAP(userLDAP, passLDAP, username); //ListLDAP.Add(ldap); var json = JsonConvert.SerializeObject(ldap); return(Content(json, "application/json")); } catch (Exception ex) { return(Ok()); } }
private void set_nUser(string user_id, string domainName) { domain = "asia"; if (domainName != "") domain = domainName; LDAP ldap = new LDAP(@"LDAP://DC=" + domain + ",DC=ad,DC=flextronics,DC=com"); if (ldap.findUser(user_id, domain)) { _isLdapUser = true; _uid = ldap.uid; using (SqlDB sqldb = new SqlDB(__conn)) { SqlCommand cmd = new SqlCommand("[sp_GAM_UsersGet]"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@uid", _uid); cmd.Parameters.AddWithValue("@domain", domain); DataTable dt = sqldb.getDataTableWithCmd(ref cmd); cmd.Dispose(); if (dt.Rows.Count == 1) { DataRow row = dt.Rows[0]; isActive = (bool)row["isActive"]; isAdmin = (bool)row["isAdmin"]; if (row["uGroup"].ToString().ToLower() == "admin") isAdmin = true; managerId = (int)row["managerId"]; isSale = (bool)row["isSales"]; isReportViewer = (bool)row["isReportViewer"]; sysUserId = (int)row["sysUserId"]; _isDbUser = true; } } userName = ldap.name; emailAddress = ldap.email; jobTitle = ldap.title; fax = ldap.fax; tel = ldap.tel; department = ldap.department; } else { _uid = ""; msg = "User not found."; } ldap.Dispose(); }