public void GetUsersInGroupMembership_ShouldThrowExceptionOnNullGroupName() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); target.GetUsersInGroupMembership(""); }
public override void ExecuteCmdlet() { CollectionVmsListResult vmList = null; ActiveDirectoryConfigResult adConfig = null; adConfig = CallClient(() => Client.Collections.GetAd(CollectionName), Client.Collections); vmList = CallClient(() => Client.Collections.ListVms(CollectionName), Client.Collections); if ((vmList != null) && (vmList.Vms != null) && (adConfig != null) && (adConfig.ActiveDirectoryConfig != null)) { IList <DirectoryEntry> staleEntries = GetVmAdStaleEntries(vmList.Vms, adConfig.ActiveDirectoryConfig, Credential); foreach (DirectoryEntry staleEntry in staleEntries) { string staleEntryCN = ActiveDirectoryHelper.GetCN(staleEntry); string shouldProcessMessage = String.Format(Commands_RemoteApp.GenericDeleteConfirmation, staleEntryCN); string verboseDescription = String.Format(Commands_RemoteApp.GenericDeleteVerboseDescription, staleEntryCN); if (ShouldProcess(verboseDescription, shouldProcessMessage, null)) { WriteVerbose(String.Format(Commands_RemoteApp.GenericVerboseDelete, staleEntryCN)); ActiveDirectoryHelper.DeleteEntry(staleEntry); WriteObject(staleEntryCN); } else { WriteVerbose(String.Format(Commands_RemoteApp.GenericVerboseSkip, staleEntryCN)); } } } }
public void Index(string login, string password) { var id = Session["AdminId"]; if (id != null) { RedirectToSiteRoot(); } if (IsPost) { if (ActiveDirectoryHelper.IsAuthenticated(login, password)) { var admin = DbSession.Query <Admin>().FirstOrDefault(a => a.UserName == login); if (admin != null && admin.Permissions.Any(p => p.Shortcut.Match("RCA"))) { Session["AdminId"] = admin.Id; FormsAuthentication.RedirectFromLoginPage(login, true); RedirectToSiteRoot(); return; } } Logger.Info("Авторизация отклонена"); Error("Не верное имя пользователя или пароль"); RedirectToAction("Index"); } }
/// <summary> /// Create a service binding based off of default credentials, /// the assumed root folder, and an assumed autodiscover email address /// </summary> /// <param name="version">EWS schema version to use. Passing NULL uses the /// EWS Managed API default value.</param> /// <param name="ewsUrl">URL to EWS endpoint. Passing NULL or an empty string /// results in a call to Autodiscover</param> /// <param name="autodiscoverAddress">Email address to use for Autodiscover. /// Passing NULL or an empty string results in a ActiveDirectory querying.</param> /// <returns>A new instance of an ExchangeService</returns> private static void InitializeWithDefaults(ExchangeVersion?version, Uri ewsUrl, string autodiscoverAddress) { RequestedExchangeVersion = version; UseDefaultCredentials = true; // If the EWS URL is not specified, use Autodiscover to find it if (ewsUrl == null) { // If no email address was given to use with Autodiscover, attempt // to look it up in Active Directory if (String.IsNullOrEmpty(autodiscoverAddress)) { autodiscoverAddress = ActiveDirectoryHelper.GetPrimarySmtp( System.Security.Principal.WindowsIdentity.GetCurrent().Name); } DoAutodiscover(autodiscoverAddress); } else { EwsUrl = ewsUrl; } try { //EWSEditor.Common.EwsEditorAppSettings oSettings = new EWSEditor.Common.EwsEditorAppSettings(); CreateExchangeService().TestExchangeService(); } catch (ServiceVersionException ex) { DebugLog.WriteVerbose("Initial requested version of Exchange2010 didn't work, trying Exchange 2007_SP1", ex); // Pass the autodiscover email address and URL if we've already looked those up InitializeWithDefaults(ExchangeVersion.Exchange2007_SP1, EwsUrl, autodiscoverAddress); } }
public void SearchUserByLoginTest_ShouldReturnCorrectADUser() { ADUser expectedUser = new ADUser() { Email = "*****@*****.**", DistinguishedName = "xxx,xxxxx,xxx123456789xxxxlocation,yyyy", DNSHostname = "my Host Name", FirstName = "Fred", LastName = "Blogs", GivenName = "Fred Blogs", Login = "******", ProfilePath = @"\\ServerName\SomeFolderOnServer", SN = "sn information", TelephoneNumber = "00 00 00 000", UserPrincipalName = "bfred", OfficeLocation = "ASTON" }; IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); ADUser actual = target.SearchUserByLogin("77777777"); Assert.AreEqual(expectedUser.Email, actual.Email); Assert.AreEqual(expectedUser.DistinguishedName, actual.DistinguishedName); Assert.AreEqual(expectedUser.DNSHostname, actual.DNSHostname); Assert.AreEqual(expectedUser.FirstName, actual.FirstName); Assert.AreEqual(expectedUser.LastName, actual.LastName); Assert.AreEqual(expectedUser.GivenName, actual.GivenName); Assert.AreEqual(expectedUser.Login, actual.Login); Assert.AreEqual(expectedUser.ProfilePath, actual.ProfilePath); Assert.AreEqual(expectedUser.SN, actual.SN); Assert.AreEqual(expectedUser.TelephoneNumber, actual.TelephoneNumber); Assert.AreEqual(expectedUser.UserPrincipalName, actual.UserPrincipalName); Assert.AreEqual(expectedUser.OfficeLocation, actual.OfficeLocation); }
public void SearchUserByName_SearchWithBothNullArgumentsShouldThrowException() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); var actual = target.SearchUserByName("", ""); }
public UserEntity Authenticate(string userName, string password) { var adHelper = new ActiveDirectoryHelper(_domainName, _adminUserName, _adminPassword); var user = adHelper.FindUser(userName); if (user == null) { return(null); } var validated = adHelper.Validate(user.UserPrincipalName, password); if (!validated) { return(null); } return(new UserEntity { Email = user.Email, Name = user.Name, Surname = user.Surname, UserPrincipalName = user.UserPrincipalName, AdLogonName = GetAdLogonName(user) }); }
public void GetEmailAddress_ShouldThrowExceptionOnNullAccountName() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); ADUser actual = target.GetEmailAddress(""); }
internal static async Task <OfaIdentity> GetIdentityAsync(string networkName) { var user = await ActiveDirectoryHelper.GetUserAsync(networkName); var directReports = await ActiveDirectoryHelper.GetDirectReportsAsync(networkName); var result = new OfaIdentity((IIdentity)user) { GivenName = user.GivenName, Surname = user.Surname, FullName = user.DisplayName, Title = user.Title, Department = user.Department, PhoneNumber = user.TelephoneNumber, EmailAddress = user.Email, Manager = PrincipalHelper.PrependDomain(user.ManagerNetworkName), DirectReports = directReports.Select(o => PrincipalHelper.PrependDomain(o.NetworkName)).ToCollection() }; result.IsManager = result.DirectReports.Any(); result.Roles = user.MemberOf.ToCollection(); return(result); }
private bool SetUpADHelper(ref string err) { err = ""; try { lock (m_Instance) { if (m_adHelper == null) { m_adHelper = new ActiveDirectoryHelper(); } if (OU_Filter.Trim().Length <= 0) { OU_Filter = m_adHelper.OU; if (OU_Filter == null) { OU_Filter = ""; } } if (OU_Filter.Trim() != m_adHelper.OU) { m_adHelper.OU = OU_Filter.Trim(); } } } catch (Exception ex) { err = "SetUpADHelper, exception: " + ex.Message; int Event_id = 6011; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } return(true); }
public void SearchUsersByLoginId_ShouldThrowExceptionOnNullAccountName() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); target.SearchUsersByLoginId(""); }
public HttpResponseMessage GetUser(string samaccount) { var adConsumer = new ActiveDirectoryHelper("opus.local"); var user = adConsumer.GetUser(samaccount); return(Request.CreateResponse(HttpStatusCode.OK, user)); }
public HttpResponseMessage GetUsers() { var adConsumer = new ActiveDirectoryHelper("opus.local"); var users = adConsumer.GetAllUsers(); return(Request.CreateResponse(HttpStatusCode.OK, users)); }
public Task <GetUserByUserNameFromAdDto> Handle(GetUserByUserNameFromAdQuery request, CancellationToken cancellationToken) { GetUserByUserNameFromAdDto getUserByUserNameFromAdDto = null; if (!string.IsNullOrWhiteSpace(request.UserName)) { using (DirectoryEntry entry = new DirectoryEntry("LDAP://" + Domain)) using (DirectorySearcher search = new DirectorySearcher(entry)) { search.PageSize = 5000; search.Filter = $"(&(objectClass=user)(|(CN=something)(sAMAccountName={request.UserName})))"; SearchResult result = search.FindOne(); if (result != null) { UserAccount userAccount = ActiveDirectoryHelper.GetUserFromResult(result); if (userAccount != null) { if (!string.IsNullOrWhiteSpace(userAccount.Department) && !string.IsNullOrWhiteSpace(userAccount.SamAccountName)) { string manager = string.Empty; if (!string.IsNullOrEmpty(userAccount.Manager)) { DirectoryEntry managerEntry = new DirectoryEntry($"LDAP://{Domain}/{userAccount.Manager}"); manager = managerEntry.Properties["samAccountName"][0].ToString(); } List <string> directReports = new List <string>(); if (userAccount.DirectReports.Any()) { foreach (string directReport in directReports.Where(d => !string.IsNullOrEmpty(d))) { DirectoryEntry managerEntry = new DirectoryEntry($"LDAP://{Domain}/{directReport}"); directReports.Add(managerEntry.Properties["samAccountName"][0].ToString()); } } getUserByUserNameFromAdDto = new GetUserByUserNameFromAdDto { UserName = userAccount.SamAccountName, DepartmentName = userAccount.Department, DirectReports = string.Join(";", directReports), FirstName = userAccount.GivenName, LastName = userAccount.SurName, ManagerName = manager, Email = userAccount.Email, JpegPhoto = userAccount.JpegPhoto }; return(Task.FromResult(getUserByUserNameFromAdDto)); } } } } } return(Task.FromResult(getUserByUserNameFromAdDto)); }
private void buttonQuery1_Click(object sender, EventArgs e) { try { richTextBoxMessage.Clear(); dtAttribute.Clear(); ActiveDirectoryHelper adHelper = new ActiveDirectoryHelper(textBoxPath.Text, textBoxAccount.Text, textBoxPassword.Text); SearchResult result = adHelper.SearchFirstOne(); if (result == null) { richTextBoxMessage.AppendText("No data."); return; } ResultPropertyCollection rpc = result.Properties; List <string> nameList = new List <string>(rpc.PropertyNames.Count); foreach (string name in rpc.PropertyNames) { nameList.Add(name); } nameList = nameList.Distinct().OrderBy(x => x).ToList(); foreach (string name in nameList) { ResultPropertyValueCollection rpvc = rpc[name]; int valueCount = rpvc.Count; foreach (object value in rpvc) { if (value == null) { continue; } string valueString = DirectoryUtility.ExtractAttributValue(name, value); richTextBoxMessage.AppendText(string.Format("{0}={1}\n", name, valueString)); DataRow drAttribute = dtAttribute.NewRow(); drAttribute["Name"] = name; drAttribute["Value"] = valueString; dtAttribute.Rows.Add(drAttribute); } } dataGridViewAttribute.Sort(dataGridViewAttribute.Columns[0], ListSortDirection.Ascending); } catch (Exception ex) { richTextBoxMessage.AppendText(ex.ToString()); } finally { richTextBoxMessage.ScrollToCaret(); } }
private string GetAccountFromAD(string familyName, string firstName, string middleName, string email) { var adEmployees = ActiveDirectoryHelper.GetEmployeesFromAd(); if (adEmployees == null) { //return string.Empty; return(null); } /*im * var foundEmployeeByCredentials = * adEmployees.Where(x => (x.ConcatenatedCredentials == familyName.ToLower() + firstName.ToLower())).ToList(); * if (foundEmployeeByCredentials.Any()) * { * if (foundEmployeeByCredentials.Count == 1) * { * var account = ACCOUNT_DOMAIN + foundEmployeeByCredentials[0].Account; * return account; * } * else * { * var accountWithMiddleName = foundEmployeeByCredentials.Where(x => x.MiddleName == middleName).ToList(); * if (accountWithMiddleName.Any() && accountWithMiddleName.Count() == 1) * { * var account = ACCOUNT_DOMAIN + accountWithMiddleName[0].Account; * return account; * } * } * } * else * { * if (email != null) * { * var foundEmployeeByEmail = adEmployees.FirstOrDefault(x => (x.Email.ToLower() == email.ToLower())); * if (foundEmployeeByEmail != null) * { * return ACCOUNT_DOMAIN + foundEmployeeByEmail.Account; * } * } * else * { * return null; * } * } */ if (email != null) { var foundEmployeeByEmail = adEmployees.FirstOrDefault(x => (x.Email.ToLower() == email.ToLower())); if (foundEmployeeByEmail != null) { return(ACCOUNT_DOMAIN + foundEmployeeByEmail.Account); } } //return string.Empty; return(null); }
public bool IsChangeUserAcctPasswordSuccess(string domainName, string userName, string newPassword) { if (!ActiveDirectoryHelper.IsUserExist(userName)) { return(false); } return(ActiveDirectoryHelper.AuthenticateUser(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", domainName, userName), newPassword)); }
private void buttonQueryAll_Click(object sender, EventArgs e) { try { richTextBoxMessage.Clear(); ActiveDirectoryHelper adHelper = new ActiveDirectoryHelper(textBoxPath.Text, textBoxAccount.Text, textBoxPassword.Text); SearchResultCollection results = adHelper.SearchAll(); if (results == null) { richTextBoxMessage.AppendText("No data."); return; } foreach (SearchResult result in results) { ResultPropertyCollection rpc = result.Properties; List <string> nameList = new List <string>(rpc.PropertyNames.Count); foreach (string name in rpc.PropertyNames) { nameList.Add(name); } nameList = nameList.Distinct().OrderBy(x => x).ToList(); foreach (string name in nameList) { ResultPropertyValueCollection rpvc = rpc[name]; int valueCount = rpvc.Count; foreach (object value in rpvc) { if (value == null) { continue; } string valueString = DirectoryUtility.ExtractAttributValue(name, value); richTextBoxMessage.AppendText(string.Format("{0}={1}\n", name, valueString)); } } richTextBoxMessage.AppendText("\n----------------------------------------------------------\n\n"); richTextBoxMessage.ScrollToCaret(); } richTextBoxMessage.AppendText($"Count: {results.Count}"); } catch (Exception ex) { richTextBoxMessage.AppendText(ex.ToString()); } finally { richTextBoxMessage.ScrollToCaret(); } }
public void GetEmailAddresses_ShouldThrowExceptionOnNullFirstName() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); string firstName = ""; string lastName = "anything"; target.GetEmailAddresses(firstName, lastName); }
public async Task <string> ADSync() { // Расстановка сортировок и уровней вложенности по отделам var depts = await _context.Departments.ToListAsync(); foreach (var d in depts) { var parentDept = depts.FirstOrDefault(x => x.Id == d.ParentId); if (parentDept != null) { parentDept.Children.Add(d); } } depts.SortByDepth(); await _context.SaveChangesAsync(); var updated = new List <Tuple <string, string, string> >(); var employees = await _context.Employees.ToListAsync(); var adusers = ActiveDirectoryHelper.GetAllUsers(); foreach (var adu in adusers) { var emp = employees.FirstOrDefault(e => e.Idguid1C.ToString() == adu.GetProperty("ipPhone")); if (emp != null && emp.Email != adu.EmailAddress && !string.IsNullOrEmpty(adu.EmailAddress)) { updated.Add(new Tuple <string, string, string>(emp.Idguid1C.ToString(), emp.Email, adu.EmailAddress)); emp.Email = adu.EmailAddress; } if (emp == null || string.IsNullOrEmpty(adu.GetProperty("ipPhone"))) { emp = employees.FirstOrDefault(e => string.IsNullOrEmpty(e.Email) && e.Name.Trim() == adu.DisplayName.Trim()); if (emp != null && emp.Email != adu.EmailAddress && !string.IsNullOrEmpty(adu.EmailAddress)) { updated.Add(new Tuple <string, string, string>(emp.Idguid1C.ToString(), emp.Email, adu.EmailAddress)); emp.Email = adu.EmailAddress; } } // Добавление доступа к странице управления по ролям в AD var groups = adu.GetAuthorizationGroups(); foreach (var g in groups) { if (g.Name.Contains("Админ")) { emp.CanManage = true; } } } return(JsonSerializer.Serialize(updated)); }
/// <summary> /// /// </summary> /// <param name="currentUser"></param> /// <param name="user"></param> /// <param name="appID"></param> /// <param name="overrideID"></param> /// <param name="userID"></param> /// <returns></returns> public string[] GetUserRoles(string currentUser, string user, string appID, string overrideID, string userID, Guid?applicationCode) { // Create instance of ADRoleLookup repository IRepository <ADRoleLookup> adRoleLookupRepository = new Repository <ADRoleLookup>(currentUser, user, appID, overrideID); IRepository <StaffAttributes> staffAttributesRepository = new Repository <StaffAttributes>(currentUser, user, appID, overrideID); IRepository <Staff> staffRepository = new Repository <Staff>(currentUser, user, appID, overrideID); IPrincipalManager principalManager = new PrincipalManager(); IActiveDirectoryHelper activeDirectoryHelper = new ActiveDirectoryHelper(staffRepository, principalManager); // Call overload with injected objects return(GetUserRoles(currentUser, user, appID, overrideID, userID, applicationCode, adRoleLookupRepository, staffAttributesRepository, activeDirectoryHelper)); }
public override bool ValidateUser(string username, string password) { ActiveDirectoryHelper activeDirectoryHelper = new ActiveDirectoryHelper(); if (MemberHelper.FindMemberByUsername(username) != null && activeDirectoryHelper.ValidateUser(username, password)) { return(true); } else { return(false); } }
private void Form1_Load(object sender, EventArgs e) { try { adHelper = new ActiveDirectoryHelper(); um = UserManager.Instance; da = new DataAccess.DataAccess(); } catch (Exception ex) { rtbMsg.AppendText("Exception: " + ex.Message); } }
public void GetEmailAddress_ShouldReturnADUserWithCorrectEmailAddress() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); ADUser expectedUser = new ADUser() { Email = "*****@*****.**", }; ADUser actual = target.GetEmailAddress("77777777"); Assert.AreEqual(expectedUser.Email, actual.Email); }
public IList <DirectoryEntry> GetVmAdStaleEntries(IList <RemoteAppVm> vmList, ActiveDirectoryConfig adConfig, PSCredential credential) { Dictionary <string, string> vmPrefixes = new Dictionary <string, string>(); List <DirectoryEntry> staleVmEntries = null; foreach (RemoteAppVm vm in vmList) { string vmNamePrefix = vm.VirtualMachineName.Substring(0, 8); // for each VM group with the same 8-character prefix, find the "minimum" VM name. // i.g, for VMs "abcdefgh0004", "abcdefgh0002", "abcdefgh0005", "abcdefgh0003" the minimum will be "abcdefgh0002" // this will be used later to determine which AD entries are stale // because each staleVMName < MIN(existingVMName) using regular case-insensitive alphanumerical comparison if (vmPrefixes.ContainsKey(vmNamePrefix)) { if (String.Compare(vm.VirtualMachineName, vmPrefixes[vmNamePrefix], StringComparison.OrdinalIgnoreCase) < 0) { vmPrefixes[vmNamePrefix] = vm.VirtualMachineName; } } else { vmPrefixes.Add(vmNamePrefix, vm.VirtualMachineName); } } staleVmEntries = new List <DirectoryEntry>(); foreach (string vmNamePrefix in vmPrefixes.Keys) { IList <DirectoryEntry> adEntries = ActiveDirectoryHelper.GetVmAdEntries( adConfig.DomainName, adConfig.OrganizationalUnit, vmNamePrefix, credential); string maxName = vmPrefixes[vmNamePrefix]; foreach (DirectoryEntry adEntry in adEntries) { string name = ActiveDirectoryHelper.GetCN(adEntry); if ((name.Length == AdHelper.VMNameLength) && (String.Compare(name, maxName, StringComparison.OrdinalIgnoreCase) < 0)) { staleVmEntries.Add(adEntry); } } } return(staleVmEntries); }
public ActionResult Index() { var loginId = User.Identity.Name; //If user Id has main name prefix var domainIdx = loginId.IndexOf("\\") + 1; if (domainIdx != -1) { loginId = loginId.Substring(domainIdx); } AdUserModel userDetails = ActiveDirectoryHelper.GetUserDetailsFromLoginId(loginId); return(View(userDetails)); }
public DiagnosticDTO Get() { Dictionary <string, string> qs = HttpRequestHelper.GetQueryStrings(Request); WritetoTrace = qs.ContainsKey("trace"); DiagnosticDTO ret = TestConnection(this.User.Identity.Name.Substring(this.User.Identity.Name.LastIndexOf(@"\") + 1)); ret.UserName = this.User.Identity.Name.Substring(this.User.Identity.Name.LastIndexOf(@"\") + 1); ret.Environment = AppSettings.Instance.Environment; //ret.EzConnectionString = LinqSQLHelper.RemoveConnectionStringSecurity(AppSettings.Instance.ConnectionString); ret.EzConnectionString = AppSettings.Instance.ConnectionString; ret.Host = AppSettings.Instance.HostName; ret.ComputerName = System.Net.Dns.GetHostName().ToLower(); ret.UserName = this.User.Identity.Name.Substring(this.User.Identity.Name.LastIndexOf(@"\") + 1); ret.DisableSecurity = false; ret.TraceEnable = false; ret.Role = "N/A"; if (ret.DiagInfo == null) { ret.DiagInfo = ""; } ret.DiagInfo += string.Format("Auth Info: AuthenticationType={0}, IsAuthenticated={1}, Name={2}, ImpersonationLevel={3}, IsAnonymous={4}", this.User.Identity.AuthenticationType, this.User.Identity.IsAuthenticated, this.User.Identity.Name, ((System.Security.Principal.WindowsIdentity) this.User.Identity).ImpersonationLevel, ((System.Security.Principal.WindowsIdentity) this.User.Identity).IsAnonymous); try { if (!AppSettings.Instance.Environment.ToLower().StartsWith("local")) { ActiveDirectoryHelper ad = new ActiveDirectoryHelper(); ADUserDetail userDetail = ad.GetUserByLoginName(ret.UserName); List <string> roles = ad.GetUserGroupMembership(ret.UserName); if (userDetail != null) { ret.FullNameFromAD = userDetail.FirstName + " " + userDetail.LastName; } } else { ret.FullNameFromAD = "N/A in LOCAL"; } } catch (Exception ex) { ret.FullNameFromAD = "N/A in LOCAL... From Error:\n" + ex.ToString(); } return(ret); }
public void GetEmailAddresses_ShouldReturnCorrectEmailAddress() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); string firstName = "anything"; string lastName = "anything"; List <string> expected = new List <string>(); expected.Add("*****@*****.**"); List <string> actual; actual = target.GetEmailAddresses(firstName, lastName); Assert.AreEqual(expected[0], actual[0]); }
public void GetUsersInGroupMembership_ShouldThrowExceptionOnNullGroupNameWithCorrectDebugInformation() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); try { target.GetUsersInGroupMembership(""); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "groupName"); return; } Assert.Fail(); }
public void SearchUsersByLoginId_ShouldThrowExceptionOnNullAccountNameWithCorrectDebugInformation() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); try { target.SearchUsersByLoginId(""); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "samAccountName"); return; } Assert.Fail(); }