private static IDirectoryAttributes AddContainerIfNecessary(Type type) { var mapping = LdapConfiguration.Configuration.Mapper.GetMapping(type); var containerCn = DnParser.ParseName(mapping.NamingContext); var containerPrefix = DnParser.ParseRDN(mapping.NamingContext); return(AddContainerIfNecessary(containerPrefix, containerCn)); }
private static void PopulateDirectoryForTests() { var user2Container = DnParser.ParseName(TestUserDirectoryContainer); var user2Prefix = DnParser.ParseRDN(TestUserDirectoryContainer); AddContainerIfNecessary(user2Prefix, user2Container); using (var context = new DirectoryContext()) { AddEntryIfNecessary("CN=PasswordUser," + TestUserDirectoryContainer, "user", context); AddEntryIfNecessary("CN=persontest," + TestUserDirectoryContainer, "user", context); AddEntryIfNecessary("CN=TestUser," + TestUserDirectoryContainer, "user", context); AddEntryIfNecessary("CN=TestUser2," + TestUserDirectoryContainer, "user", context); } var roleContainer = DnParser.ParseName(RolesDirectoryContainer); var rolePrefix = DnParser.ParseRDN(RolesDirectoryContainer); AddContainerIfNecessary(rolePrefix, roleContainer); using (var context = new DirectoryContext()) { IDirectoryAttributes rangeTest = AddEntryIfNecessary("CN=RangeTest," + RolesDirectoryContainer, "group", context); foreach (var kvp in rangeTest.Where(kvp => kvp.Key.StartsWith("member", StringComparison.OrdinalIgnoreCase))) { if (kvp.Value is IEnumerable <string> && ((IEnumerable <string>)kvp.Value).Any()) { Console.WriteLine("RangeTest members already populated"); return; } } var newMembers = new List <string>(); newMembers.AddRange(context.Query <LdsUser>().Take(10000).Select(u => u.DistinguishedName)); rangeTest.Set("member", newMembers); context.Update(rangeTest); } }
public void ParseRDN_NullDn_ThrowsException() { Executing.This(() => DnParser.ParseRDN(null)) .Should().Throw <ArgumentException>(); }
public void ParseRDN_MultipleCharacters_ReturnsPrefix() { DnParser.ParseRDN("XYZ=test,Dd=domain,Dd=com").Should().Be.EqualTo("XYZ"); }
public void ParseRDN_SingleCharacter_ReturnsPrefix() { DnParser.ParseRDN("n=test,Dd=domain,Dd=com").Should().Be.EqualTo("n"); }