Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3gYJ-0005fC-8b for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 13:02:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i3gYH-0001tS-R0 for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 13:02:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3gVb-0002ZJ-PH for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 13:00:08 +0000 Received: from srvimsva2.dst.dk ([91.208.143.64]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3gVY-0007pK-Iq for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 13:00:06 +0000 Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A0E210406C; Fri, 30 Aug 2019 15:00:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dst.dk; s=dmz20180119; t=1567170003; bh=xlsChOEsbSJndtuCLYU3ldrMRMzWF7AoMwDNawiD1rY=; h=From:To:Date; b=KSjT29YRAv1K8Ma3fbrHV5t4T0aXWzQbeAehsfdLTa4pa5UzUiy3tuwATRMN+HuU3 aGahXxG7XK2s+36t1OePQjPQcJZbiUaEWK+08yRJk1xFFyGWk4Zfiqo3wQU2Uuenkb J4eXGIPBofROhdAA/QM+2ihZfcg+YnfpmG6Uoywo= Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EC7A10406A; Fri, 30 Aug 2019 15:00:03 +0200 (CEST) Received: from Sepo.dst.dk (unknown [192.168.64.11]) by srvimsva2.dst.dk (Postfix) with ESMTP; Fri, 30 Aug 2019 15:00:03 +0200 (CEST) Received: from SRVEXC6.dst.local ([172.30.32.195]) by Sepo.dst.dk (JAMES SMTP Server 2.3.2-1) with SMTP ID 701; Fri, 30 Aug 2019 15:00:03 +0200 (CEST) Received: from SRVEXC5.dst.local ([fe80::60d0:9a80:c5c6:339c]) by SRVEXC6.dst.local ([fe80::952:2aa9:6795:771%13]) with mapi id 14.03.0415.000; Fri, 30 Aug 2019 15:00:02 +0200 From: Niels Jespersen To: Magnus Hagander CC: "pgsql-general@lists.postgresql.org" Subject: Re: SSPI auth and mixed case usernames Thread-Topic: SSPI auth and mixed case usernames Thread-Index: AdVfJTnb7rpeCvDXTjqWJgPws8lTDf//4OWAgAA6U+M= Date: Fri, 30 Aug 2019 13:00:01 +0000 Message-ID: References: <3967181ED595B445B1E39718204FD4BD0122BAD97D@SRVEXC5.dst.local>, In-Reply-To: Accept-Language: da-DK, en-US Content-Language: da-DK X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-TM-AS-GCONF: 00 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk
Hello Magnus

Thank you for your prompt reply. 

I=92m not sure I understand your last statement. I want to achieve that re= gardless of the case of the entered username is logged into the same Postgr= es user (whose name is created in all lowercase).

In other words, Windows usernames one day entered as XYz, the next day ent= ered as xYz, should logon to Postgres user xyz.

Niels



Fra: Magnus Hagander <magnus@hagander.net>
Dato: 30. august 2019 kl. 13.31.33 CEST
Til: Niels Jespersen <NJN@dst.dk>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postg= resql.org>
Emne: Re: SSPI auth and mixed case usernames



On Fri, Aug 30, 2019 at 1:27 PM Niels= Jespersen <NJN@dst.dk> wrote:
Hello

Postgresql 11.2 on Windows.

I have a user mapping i pg_hba.conf

sspi map=3Ddomain

In pg_ident.conf, I have the following:

domain        /^(([A-Z|a-z]{3}[A|a]?)|([Xx]\d{2}))@DOMA= IN$    \1

This maps windows logonname til a postgres username. Hower, for reasons I c= annot explain, sometimes the username comes in all-lowercase, at other time= s it comes all-caps. This is dependant on the Windows host the client is co= nnected to.

It is actually dependent on what the user typed into their login box w= hen they logged in to the machine. Yes, that's mostly insane, but that's ho= w those APIs in Windows work.


I do not want to create both XXX and xxx as users on Postgres. I would pref= er to translate alle usernames to lowercase in the map.

Is that possible, and if so, how? 

No, PostgreSQL will not do that automatically for you. 

What pg_ident.conf allows you to do is say that the user is allowed to= log in to the postgres user in lowercase even if the username retrieved us= ing sspi is not in lowercase. But the application still has to actually try= to log in with lowercase, and do so before it connects to PostgreSQL.
 
--