"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
--