Location: List Archives

List Archives

This forum is an archive of all posts to our mailing list over the past few years.  The forum is set read only therefore to contribute you will need to join our list community.  See more info about this here.

 

When subscribed to the list you should use your standard email client to send your posts to ActiveDir@mail.activedir.org.

List Archives

Subject: [ActiveDir] How to check the SAMAccount name for user account
Prev Next
You are not authorized to post a reply.

AuthorMessages
mohanravUser is Offline

Posts:82

05/25/2010 6:57 PM  
Hi Team,

What is the command to get the SAMAccount name for an user account?

--
Regards,
Mohan R
Level2-Server support Engineer.

its.mikeUser is Offline

Posts:12

05/25/2010 7:34 PM  
probably a tidier method (which I look forward to seeing), but from a cmd
prompt you could:



for /f "tokens=*" %a in ('dsquery user -name *smith*') do @dsquery * %a
-attr sAMAccountName distinguishedName | find /i /v "distinguishedName"



and in a .cmd script:



for /f "tokens=*" %%a in ('dsquery user -name *smith*') do dsquery * %%a
-attr sAMAccountName distinguishedName | find /i /v "distinguishedName"



From: activedir-owner@mail.activedir.org
[mailto:activedir-owner@mail.activedir.org] On Behalf Of Mohan Ravindran
Sent: Tuesday, May 25, 2010 10:56 am
To: activedir
Subject: [ActiveDir] How to check the SAMAccount name for user account



Hi Team,



What is the command to get the SAMAccount name for an user account?

--
Regards,
Mohan R
Level2-Server support Engineer.




its.mikeUser is Offline

Posts:12

05/25/2010 7:40 PM  
This is a little better (-attr lets you pick ad hoc Active Directory
attributes.. this time I've picked sAMAccountName and the canonical name):



dsquery * -filter "(&(sn=*smith*)(objectCategory=Person)(ObjectClass=user))"
-attr sAMAccountName cn



From: activedir-owner@mail.activedir.org
[mailto:activedir-owner@mail.activedir.org] On Behalf Of mike Mitchell
Sent: Tuesday, May 25, 2010 11:34 am
To: activedir@mail.activedir.org
Subject: RE: [ActiveDir] How to check the SAMAccount name for user account



probably a tidier method (which I look forward to seeing), but from a cmd
prompt you could:



for /f "tokens=*" %a in ('dsquery user -name *smith*') do @dsquery * %a
-attr sAMAccountName distinguishedName | find /i /v "distinguishedName"



and in a .cmd script:



for /f "tokens=*" %%a in ('dsquery user -name *smith*') do dsquery * %%a
-attr sAMAccountName distinguishedName | find /i /v "distinguishedName"



From: activedir-owner@mail.activedir.org
[mailto:activedir-owner@mail.activedir.org] On Behalf Of Mohan Ravindran
Sent: Tuesday, May 25, 2010 10:56 am
To: activedir
Subject: [ActiveDir] How to check the SAMAccount name for user account



Hi Team,



What is the command to get the SAMAccount name for an user account?

--
Regards,
Mohan R
Level2-Server support Engineer.


barkillsUser is Offline

Posts:201

05/26/2010 4:25 PM  
With what input?

As asked, I might assume the input is the interactively logged in user, in which case, you can simply use the Windows environment variable %username%, i.e. from a command prompt type 'set username' and get back the samAccountName.

From: activedir-owner@mail.activedir.org [mailto:activedir-owner@mail.activedir.org] On Behalf Of Mohan Ravindran
Sent: Tuesday, May 25, 2010 10:56 AM
To: activedir
Subject: [ActiveDir] How to check the SAMAccount name for user account

Hi Team,

What is the command to get the SAMAccount name for an user account?

--
Regards,
Mohan R
Level2-Server support Engineer.


You are not authorized to post a reply.
Forums >ActiveDir Mail List Archive >List Archives > [ActiveDir] How to check the SAMAccount name for user account



ActiveForums 3.7
Friends

Friends

VisualClickButoton
Members

Members

MembershipMembership:
Latest New UserLatest:MrPTSai
New TodayNew Today:0
New YesterdayNew Yesterday:0
User CountOverall:5234

People OnlinePeople Online:
VisitorsVisitors:22
MembersMembers:0
TotalTotal:22

Online NowOnline Now:

Ads

Copyright 2009 ActiveDir.org
Terms Of Use