Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 89FB0E0C96A for ; Sat, 16 Jun 2012 09:36:37 -0300 (ADT) Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SfsF1-0006tr-PX for pgsql-admin@postgresql.org; Sat, 16 Jun 2012 12:36:37 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SfsEj-0003GH-L3 for pgsql-admin@postgresql.org; Sat, 16 Jun 2012 14:36:17 +0200 Received: from p5081fd74.dip.t-dialin.net ([80.129.253.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Jun 2012 14:36:17 +0200 Received: from chris by p5081fd74.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 16 Jun 2012 14:36:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Christian Ullrich Subject: Re: How to setup PostgreSQL using Windows Authentication? Date: Sat, 16 Jun 2012 14:36:02 +0200 Lines: 45 Message-ID: References: <583566AE01BD5948A12C964BD739A9A24686BA6A@HARRY.sfcu.intr> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p5081fd74.dip.t-dialin.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: <583566AE01BD5948A12C964BD739A9A24686BA6A@HARRY.sfcu.intr> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/76 X-Sequence-Number: 39667 * Peter Cheung wrote: > I’m new to PostgreSQL. I installed PostgreSQL on a Windows Server 2008 > R2 server. I have created a database and an user in Windows Active > Directory. How can I configure that user to access that database? The one-click installer (assuming you used that) left you with PostgreSQL running under a local account named "postgres". First, you have to change that, because SSPI requires that the service uses a domain account: 1. Create a user account in your domain. 2. Change the ownership of the data directory and everything within it to the new account, and grant it full control. 3. Change the service log on credentials so the service uses your domain account. 4. Start the service to see if everything works. Try logging on as before, create a database, drop some tables, call pg_switch_xlog(). If you can log on at all, just about anything that goes wrong later indicates missing permissions on the data files. Now, you have to tell Active Directory that your service account is running the database. For that, you add a Service Principal Name to your service account. You can do that with a command line tool named setspn.exe, of which I cannot remember the command line. You can also just change the attribute (servicePrincipalName) directly using either the "Users and Computers" MMC, or whatever 2008R2's replacement for that is, or ADSIedit. Anyway, your new SPN is POSTGRES/fully.qualified.host.name In my experience (which may be incomplete), you also have to make sure that all your clients use the full host name, because otherwise they may not get service tickets. Adding a second SPN with just the host name without the domain may help with that, but using the full name is better anyway. The last step is to allow SSPI logon to the database. For that, you need to create some login roles that have the same name as your domain users, and an entry in pg_hba.conf with authentication method "sspi". Remember that only the first entry in pg_hba.conf that matches database, client address, and claimed user name is used. -- Christian