Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Active Directory > Active Directory Query

Reply
Thread Tools Display Modes

Active Directory Query

 
 
Nik
Guest
Posts: n/a

 
      04-09-2010
Guys,
I have a list of users in a .csv file. The users are listed via firstName,
lastName
Is there anyway I can use dsquery or any other tools to grab the user's
login id after it's compared to the name?
Normally for a single name I would do something like
dsquery user -name "Nik Test" | dsget user -samid
Win2003 sp2
Thanks


 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      04-10-2010

"Nik" <test> wrote in message news:...
> Guys,
> I have a list of users in a .csv file. The users are listed via firstName,
> lastName
> Is there anyway I can use dsquery or any other tools to grab the user's
> login id after it's compared to the name?
> Normally for a single name I would do something like
> dsquery user -name "Nik Test" | dsget user -samid
> Win2003 sp2
> Thanks
>


Best would be to use Ambiguous Name Resolution (ANR), but dsquery does not
support any LDAP filters, so ANR is not supported. You could use a tool like
Joe Richards' free adfind. See this link:

http://www.joeware.net/freetools/tools/adfind/index.htm

For example, to find all users where first name is "James" and last name is
"Smith", you could use the following to find the "Pre-Windows 2000 logon"
name (sAMAccountName) of each such user in MyDomain.com:

adfind -b "dc=MyDomain,dc=com" -f "(anr=James Smith)" sAMAccountName

For more on using ANR see this link:

http://www.rlmueller.net/AmbiguousNameResolution.htm

And I have an example VBScript program that performs generic searches in AD
using ADO at this link:

http://www.rlmueller.net/GenericADO.htm

This program prompts for the "base" of the query (defaults to entire
domain), the LDAP filter, for example (anr=James Smith), and the names of
the attribute values to retrieve.

Another option would be a more specific filter, like:

(&(sn=Smith)(givenName=James))

where sn (surname) is the name of the attribute corresponding to the user
last name, and givenName is the user first name. This filter returns all
objects where the two conditions are true. Does this help?

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
Nik
Guest
Posts: n/a

 
      04-15-2010

Thanks guys

"Richard Mueller [MVP]" <rlmueller-> wrote in
message news:...
>
> "Nik" <test> wrote in message
> news:...
>> Guys,
>> I have a list of users in a .csv file. The users are listed via
>> firstName, lastName
>> Is there anyway I can use dsquery or any other tools to grab the user's
>> login id after it's compared to the name?
>> Normally for a single name I would do something like
>> dsquery user -name "Nik Test" | dsget user -samid
>> Win2003 sp2
>> Thanks
>>

>
> Best would be to use Ambiguous Name Resolution (ANR), but dsquery does not
> support any LDAP filters, so ANR is not supported. You could use a tool
> like Joe Richards' free adfind. See this link:
>
> http://www.joeware.net/freetools/tools/adfind/index.htm
>
> For example, to find all users where first name is "James" and last name
> is "Smith", you could use the following to find the "Pre-Windows 2000
> logon" name (sAMAccountName) of each such user in MyDomain.com:
>
> adfind -b "dc=MyDomain,dc=com" -f "(anr=James Smith)" sAMAccountName
>
> For more on using ANR see this link:
>
> http://www.rlmueller.net/AmbiguousNameResolution.htm
>
> And I have an example VBScript program that performs generic searches in
> AD using ADO at this link:
>
> http://www.rlmueller.net/GenericADO.htm
>
> This program prompts for the "base" of the query (defaults to entire
> domain), the LDAP filter, for example (anr=James Smith), and the names of
> the attribute values to retrieve.
>
> Another option would be a more specific filter, like:
>
> (&(sn=Smith)(givenName=James))
>
> where sn (surname) is the name of the attribute corresponding to the user
> last name, and givenName is the user first name. This filter returns all
> objects where the two conditions are true. Does this help?
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Denied error while edit some of the GPOs in Windows 2003 AD Laljeev M Active Directory 24 03-25-2010 01:40 PM
Re: Active Directory problems/dcdiag error kj [SBS MVP] Windows Small Business Server 3 03-24-2010 09:19 PM
Re: DC with "Windows cannot obtain the domain controller name for your computer network" Danny Sanders Active Directory 0 01-21-2010 02:26 PM
Error: Agent failed detecting with reason: 0x80248008 (WSUS client AAM Windows Server 0 12-30-2009 03:26 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59