Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1054
  • Last Modified:

can dsquery be nested, ActiveDirectory?

Hi,

From dos prompt or within batch file how can i add sub query with in Dsquery. for Active Directory

example: i want to combine (or execute) following  query's together ..as i want to use output from one query(a) as input for other (b)
a) dsquery user -samid joh*
b) dsget user "CN=John K. Savill,CN=Users,DC=uk,DC=savilltech,DC=com" -memberof

if cmd>>dsquery user -samid joh*    ------return  some string xxxx
i want to use this xxxx inside...(query b)
 dsget user xxxx -memberof
0
kishan66
Asked:
kishan66
  • 3
1 Solution
 
oBdACommented:
Just pipe them together:
dsquery user -samid joh* | dsget user -memberof
0
 
kishan66Author Commented:
hi oBdA,

wow that works gr8

can i also combine dsquery with dos command "whoami"

example : combine
a) dsquery user -samid joh*
b) whoami

some thing like ....   dsquery user -samid whoami  (sorry for lack for knowledge)

i would really appreciate that
0
 
oBdACommented:
That depends mainly on whether the application accepts input from stdin.
Even if the next application requires a certain command line, you can capture the input from a command and use it in the next one:
A simple batch file:
for /f "delims=" %%a in ('dsquery user -samid joh*') do set UserDN=%%a
echo User's DN: %UserDN%

Open in new window

Whether anything of that works depends on the syntax of the command. The standard whoami.exe from Microsoft's Support Tools only displays information about the current user, so it can't use a user DN.
0
 
oBdACommented:
A nice scripting resource, by the way, is http://www.robvanderwoude.com/
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now