Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id AA37DAD7E2F for ; Sun, 17 Jun 2012 06:30:43 -0300 (ADT) Received: from mail-pz0-f46.google.com ([209.85.210.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SgBod-0008MI-EY for pgsql-admin@postgresql.org; Sun, 17 Jun 2012 09:30:42 +0000 Received: by dady13 with SMTP id y13so5795605dad.19 for ; Sun, 17 Jun 2012 02:30:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=1YeabV3kgzvrTcKUfRx6DC5SbRMnwPfFxnCGVzZ8PHs=; b=JzMuKlxFKWqGlt8OXFBFcGnemKR4vqlVtbgGL4h2ukojwj9NTWrOKlvgYvI2QZpaGI xEl2yHJMnf9dhivbfo+/oSDLoFTHOW1Q3uUzjn3JX7ylhKlOJsJoNq7sHqds78Hg5g2V /O/UXcB+zKikfyMtazkQRMKnQwdYzH9iRXz1v/GBo7WzIxyk8gTIKWk+Z0FkqaHVxsO0 OXOBliQHCdYDyqdJrV5k+Fhi7kIkH5MWxbLUQ9XXAGtsJLk5bRMQVXHOEQuHBsnpypnk RalmUS6Ut3oUfn5jkWYtSJo1uHY2XosagQ2MaBcdeCZH9Q7fbWeKsRDIFPEERjij6MoY CVZA== Received: by 10.68.125.228 with SMTP id mt4mr2701818pbb.21.1339925422653; Sun, 17 Jun 2012 02:30:22 -0700 (PDT) Received: from ayaki.localdomain (58-7-107-203.dyn.iinet.net.au. [58.7.107.203]) by mx.google.com with ESMTPS id hf5sm12084968pbc.4.2012.06.17.02.30.19 (version=SSLv3 cipher=OTHER); Sun, 17 Jun 2012 02:30:21 -0700 (PDT) Message-ID: <4FDDA3A8.4030307@ringerc.id.au> Date: Sun, 17 Jun 2012 17:30:16 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Christian Ullrich CC: pgsql-admin@postgresql.org Subject: Re: How to setup PostgreSQL using Windows Authentication? References: <583566AE01BD5948A12C964BD739A9A24686BA6A@HARRY.sfcu.intr> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gm-Message-State: ALoCoQk1VDqG8NWnxBbYukzrmbgZxjklBovrZPQlLR14m95svgosNVF3pyD5/hj4YGZC6QqW8rLC X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/78 X-Sequence-Number: 39669 On 06/16/2012 08:36 PM, Christian Ullrich wrote: > * 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: That's a great explanation. I didn't see anything equivalent in the docs - am I just blind? If not documented anywhere I'd like to add that to the wiki. > > 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 > >