Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBfr8-0003pd-CV for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 15:32:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBfr6-0003If-Uw for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 15:32:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBfr6-0003Hx-Mu for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 15:32:08 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBfqz-0006wt-QL for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 15:32:08 +0000 Received: by mail-ej1-x634.google.com with SMTP id w1so11714229ejf.11 for ; Mon, 15 Feb 2021 07:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=OZpsIT8CuvRAJyuBMqrzPkD3GKuDcpMyXrot+5fR47c=; b=sClCtw5MYbAYhujsdC/pdEsIZGV2KTh7OHgj5i9ldJKLJvEiLWYBVYNkoVDzjGabwj 6q79RtqQhWZumSZSqh7IL/IWvR42BLRC7N6R2m3rrfgEobqHB48kxTU4C9ARdXRWsdnV lM2s3/t1I7MJgwSHGnk9Tbhf2BfhC7ZfnHChg2x3FaZFeJPsWL5qB4HAYDssL8uGjcBu FsNd9qTr+uADCB1hraSYiks0rsYbEypLTwVJDLCaG4Sxe0a2lwPUlnVZTR9LS1MaJ52t Ha025j8xK2QR9dCQn/B5ulyD62RUIooA7Dgk2Zzm44zk5hOjddpuvg/zDTzRB7qvAaJs tMhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=OZpsIT8CuvRAJyuBMqrzPkD3GKuDcpMyXrot+5fR47c=; b=VQlrgBOv3EvqKtjrg4HiiqOy8spHoQWoNa/KwEKjWRy/H4AUIiNwjQFV6oV1CsF6sl 71+iQ4n8mOc37Cs0b5GewM82wFvhjvp1E6aXXtvEklP29z1FJapmORikBAbjBi6HfwsG 5qdcNsZYY7gYKwaRyGAdFZ0s85IW0Hpq/dU5PbQKvgaJYgGN9baZkRJd6r6Cw8BdD1/F UffdW7/yB0U1Ru6TNykbrNLBWlhV5VXSmigMfAELPiB7z6F9wmhBHyYOn8YJbNawO6Qk rLKy7szlo2nNfIgQqn3D4aS+twJfdysfuw4/Q1DgB6/iYu6BGN60RdHUTjRoLK6hBl9G WQHw== X-Gm-Message-State: AOAM533v8g5n0I7GdCAv+La2n/ck9KEYDwNuM8VWjzldR65E8/Ly64Mj POfcClHoXsYly4RbsgS6T9+zeQ== X-Google-Smtp-Source: ABdhPJzD5Kr4lYciP1Vf+PivbgpoyIoE3RW1dReLhIrdOArziGcp+GC2LNLQPJ6To9MtLK/ImYLM/A== X-Received: by 2002:a17:907:2ace:: with SMTP id fm14mr16118039ejc.475.1613403118068; Mon, 15 Feb 2021 07:31:58 -0800 (PST) Received: from localhost.localdomain (217-149-170-190.nat.highway.telekom.at. [217.149.170.190]) by smtp.gmail.com with ESMTPSA id i21sm10362516edy.9.2021.02.15.07.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 07:31:57 -0800 (PST) Message-ID: <30cb04ee32d1690a2d1b2a3efd1a53d5112d2d7c.camel@cybertec.at> Subject: Re: [LDAPS] Test connection user with ldaps server From: Laurenz Albe To: =?ISO-8859-1?Q?Jo=E3o?= Gaspar , pgsql-general@lists.postgresql.org Date: Mon, 15 Feb 2021 16:31:56 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 2021-02-13 at 10:36 +0000, João Gaspar wrote: > I have a PostgreSQL 13.1 (RHEL 8.3) Server and I want to configure the pg_hba.conf with a remote ldaps server. > > My steps: > > I create a PostgreSQL user1 with superuser role to test the ldaps authentication method in the terminal client. > > Modify the pg_hba.conf to: > > host all all 0.0.0.0/0 ldap ldapurl="ldaps://serverurl:636/DC=company,DC=example,DC=com?sAMAccountName?sub" ldapbinddn="user-to-do-autentication-ldap- > connection" ldapbindpasswd=" user-ldap-connection password-autentication" > > Save and restart the PostgreSQL service. > > Try to connect with the terminal client with psql -h postgresqlremoteserverhost -U user1 and after putting the password give the following error: > psql: FATAL: LDAP authentication failed for user "user1" > > I validate the ldap user1 with ldapsearch (in the RHEL host) and the user1 appears in the ldapsearch correctly using the same ldapurl, ldapbinddn and ldapbinpasswd. > > Checking the remote postgresql logs, the connection to the remote ldaps do the correct authentication but can´t search by the attribute sAMAccountName. Here is the PostgreSQL log: > could not search LDAP for filter "(sAMAccountName=user1)" on server "serverurl": Operations error 2021-02-13 10:02:54.679 WET [1127801] DETAIL: LDAP diagnostics: 000004DC: LdapErr: DSID-0C0907E9, > comment: To perform this operation a successful bind must be completed on the connection., data 0, v2580 > > Info: The user1 was created as well in the ldaps server with sAMAccountName user1. > > It seems that the problem is in the pg_hba.conf how to tell the search, can anyone have similar problem ou resolution? That error looks strange to me, but I am not an LDAP expert. Your configuration seems fine to me, and if it gets to search, it must have bound to "DC=company,DC=example,DC=com?sAMAccountName" as the "ldapbinddn" first. What I would do is experiment with the "ldapsearch" executable from OpenLDAP and see if you can reproduce the problem from the command line. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com