public inbox for gentoo-server@lists.gentoo.org
 help / color / mirror / Atom feed
From: Brian Kroth <bpkroth@gmail.com>
To: Pandu Poluan <pandu@poluan.info>
Cc: gentoo-server@lists.gentoo.org
Subject: Re: [gentoo-server] Extract usernames from Active Directory
Date: Tue, 28 Jun 2011 23:05:39 -0500	[thread overview]
Message-ID: <20110629040538.GL22410@gmail.com> (raw)
In-Reply-To: <cS1srcddFlXS.WFjGCQhD@smtp.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

Pandu Poluan <pandu@poluan.info> 2011-06-29 09:00:
> -original message-
> Subject: Re: [gentoo-server] Extract usernames from Active Directory
> From: mRyOuNg <mryoung@soundbomb.net>
> Date: 2011-06-29 04:44
>
>> What about an easy ldap request selecting only samaccountname?
>
> Yup, that's the plan. How do I do that?

ldapsearch -h your-ad-dc.your.domain -b 

Something like this:
# ldapsearch -Z -W -x -H ldap://your-ad-dc.your.domain -b ou=Users,dc=your,dc=domain -D cn=$USER,ou=Users,dc=your,dc=domain cn=$USER samaccountname

pipe through some grep | sed to get just the user names.

The catch is that by default AD won't allow anonymous binds, so you need 
to authenticate to the server to perform the ldapsearch (-D, -W).  To do 
that you usually need to use a secure connection (-Z).  Obviously for 
automated things you should use a service account.  -b tells your search 
where to start looking.  cn=$USER is what to look for (called the search 
filter).  samaccountname is what to return (just a list of attribute 
names, or nothing to return them all).  

I don't recall what it's called exactly atm as I try not to touch 
Windows anymore, but if you dig through mmc on a server machine you 
should be able to find something called adsiedit, or some such, that 
will allow you to browse the actual ldap schema and tree.  That'll help 
inform you what the parameters for each of the above settings should 
actually be in your case.

This is just a simple example.  You can get really fancy with ldap 
search filters or hooking all your stuff up to it through pam for local 
auth.  I'd suggest you use a recent windows server version for that as 
the schema bits necessary to serve unix details seem to be a little bit 
more sane these days.

Hope that helps,
Brian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2011-06-29  5:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29  2:00 [gentoo-server] Extract usernames from Active Directory Pandu Poluan
2011-06-29  4:05 ` Brian Kroth [this message]
2011-06-29  9:25   ` [gentoo-server] Old Gentoo server - portage outdated - how to upgrade in-place Todd Hebert
2011-06-29 10:07     ` Denis Bondar
2011-06-29 11:17       ` Todd Hebert
  -- strict thread matches above, loose matches on Subject: below --
2011-06-29  1:58 [gentoo-server] Extract usernames from Active Directory Pandu Poluan
2011-06-29  1:22 Pandu Poluan
2011-06-28 18:41 Pandu Poluan
2011-06-28 19:52 ` Ryan Gibbons
2011-06-28 21:07 ` Alessandro Ratti
2011-06-28 21:44 ` mRyOuNg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110629040538.GL22410@gmail.com \
    --to=bpkroth@gmail.com \
    --cc=gentoo-server@lists.gentoo.org \
    --cc=pandu@poluan.info \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox