public void ProtocolVersion_SetInvalid_ThrowsLdapException(int value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Throws <LdapException>(() => options.ProtocolVersion = value); } }
public void HostReachable_Get_ReturnsTrue() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.True(options.HostReachable); } }
public void StopTransportLayerSecurity_NotStarted_ThrowsTlsOperationException() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Throws <TlsOperationException>(() => options.StopTransportLayerSecurity()); } }
public void SecurityContext_GetNotStarted_ThrowsDirectoryOperationException() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Throws <DirectoryOperationException>(() => options.SecurityContext); } }
public void SaslMethod_Set_ThrowsLdapException() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.SaslMethod); Assert.Throws <LdapException>(() => options.SaslMethod = "SaslMethod"); } }
public void ReferralChasing_Set_GetReturnsExpected(ReferralChasingOptions value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(ReferralChasingOptions.All, options.ReferralChasing); options.ReferralChasing = value; Assert.Equal(value, options.ReferralChasing); } }
public void LocatorFlag_Set_GetReturnsExpected(LocatorFlags value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(LocatorFlags.None, options.LocatorFlag); options.LocatorFlag = value; Assert.Equal(value, options.LocatorFlag); } }
public void ReferralHopLimit_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(32, options.ReferralHopLimit); options.ReferralHopLimit = 10; Assert.Equal(10, options.ReferralHopLimit); } }
public void SendTimeout_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(TimeSpan.FromSeconds(-1), options.SendTimeout); options.SendTimeout = TimeSpan.FromSeconds(10); Assert.Equal(TimeSpan.FromSeconds(10), options.SendTimeout); } }
public void ReferralCallback_Get_ReturnsException() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.ReferralCallback.DereferenceConnection); Assert.Null(options.ReferralCallback.NotifyNewConnection); Assert.Null(options.ReferralCallback.QueryForConnection); Assert.Same(options.ReferralCallback, options.ReferralCallback); } }
public void RootDseCache_Set_GetReturnsExpected(bool value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.True(options.RootDseCache); options.RootDseCache = value; Assert.Equal(value, options.RootDseCache); } }
public void TcpKeepAlive_Set_GetReturnsExpected(bool value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.False(options.TcpKeepAlive); options.TcpKeepAlive = value; Assert.Equal(value, options.TcpKeepAlive); } }
public void SspiFlag_Set_GetReturnsExpected(int value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(16386, options.SspiFlag); options.SspiFlag = value; Assert.Equal(value, options.SspiFlag); } }
public void SecureSocketLayer_Set_GetReturnsExpected(bool value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.False(options.SecureSocketLayer); options.SecureSocketLayer = value; Assert.False(options.SecureSocketLayer); } }
public void AutoReconnect_Set_GetReturnsExpected(bool value) { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.True(options.AutoReconnect); options.AutoReconnect = value; Assert.Equal(value, options.AutoReconnect); } }
public void PingKeepAliveTimeout_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(TimeSpan.FromMinutes(2), options.PingKeepAliveTimeout); options.PingKeepAliveTimeout = TimeSpan.FromSeconds(10); Assert.Equal(TimeSpan.FromSeconds(10), options.PingKeepAliveTimeout); } }
public void HostName_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.HostName); //TODO: will fail with openLdap/*nix, "ldap_init" sets LDAP_OPT_HOST_NAME, so HostName=="server:389" options.HostName = "HostName"; Assert.Equal("HostName", options.HostName); options.HostName = null; Assert.Equal("HostName", options.HostName); } }
public void VerifyServerCertificate_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.VerifyServerCertificate); options.VerifyServerCertificate = VerifyServerCertificate; Assert.Equal(VerifyServerCertificate, options.VerifyServerCertificate); options.VerifyServerCertificate = null; Assert.Null(options.VerifyServerCertificate); } }
public void QueryClientCertificate_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.QueryClientCertificate); options.QueryClientCertificate = QueryClientCertificate; Assert.Equal(QueryClientCertificate, options.QueryClientCertificate); options.QueryClientCertificate = null; Assert.Null(options.QueryClientCertificate); } }
public void ProtocolVersion_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Equal(2, options.ProtocolVersion); options.ProtocolVersion = 3; Assert.Equal(3, options.ProtocolVersion); options.ProtocolVersion = 2; Assert.Equal(2, options.ProtocolVersion); } }
public void DomainName_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; Assert.Null(options.DomainName); options.DomainName = "DomainName"; Assert.Equal("DomainName", options.DomainName); options.DomainName = null; Assert.Null(options.DomainName); } }
private void lockedLdapBind(LdapConnection current, NetworkCredential creds, ContextOptions contextOptions) { AuthType authType; bool flag; bool flag1; LdapConnection ldapConnection = current; if ((ContextOptions.SimpleBind & contextOptions) > 0) { authType = AuthType.Basic; } else { authType = AuthType.Negotiate; } ldapConnection.AuthType = authType; LdapSessionOptions sessionOptions = current.SessionOptions; if ((ContextOptions.Signing & contextOptions) > 0) { flag = true; } else { flag = false; } sessionOptions.Signing = flag; LdapSessionOptions ldapSessionOption = current.SessionOptions; if ((ContextOptions.Sealing & contextOptions) > 0) { flag1 = true; } else { flag1 = false; } ldapSessionOption.Sealing = flag1; if (creds.UserName != null || creds.Password != null) { current.Bind(creds); return; } else { current.Bind(); return; } }
public void ReferralCallback_Set_GetReturnsExpected() { using (var connection = new LdapConnection("server")) { LdapSessionOptions options = connection.SessionOptions; var value = new ReferralCallback { DereferenceConnection = ReferralCallbackTests.DereferenceConnection, NotifyNewConnection = ReferralCallbackTests.NotifyNewConnection, QueryForConnection = ReferralCallbackTests.QueryForConnection }; options.ReferralCallback = value; Assert.Same(value, options.ReferralCallback); options.ReferralCallback = null; Assert.Null(options.ReferralCallback); } }
public static LdapConnection Connect() { LdapConnection ldapConnection = null; try { LdapDirectoryIdentifier ldapIdentifier = new LdapDirectoryIdentifier(server, portNumber, true, false); ldapConnection = new LdapConnection(ldapIdentifier); ldapConnection.Credential = new NetworkCredential(userName, password); ldapConnection.AuthType = AuthType.Basic; LdapSessionOptions options = ldapConnection.SessionOptions; options.ProtocolVersion = 3; ldapConnection.Bind(); return(ldapConnection); } catch (Exception e) { _logger.Error("Error connecting to LDAP server: " + e); throw e; } }