Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use dsquery-result as a variable?

969 views
Skip to first unread message

di...@tabken-online.de

unread,
Mar 16, 2007, 10:26:25 AM3/16/07
to
Hi folks,
just a newbie-question about using variables:

How can I use the result of a dsquery user-statement in a variable in
dos-batchfile?
I'd like to read the DN of an AD-User by passing
dsquery user
OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla -samid
qx64209
and use the result
"CN=Dimo
Tabken,OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla"
as a variable called UserDN.
Unfortunately I don't have an idea how to do this ...
set UserDN=dsquery user
OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla -samid
qx64209
would probably work in VB / VBA ... but it doesn't in my batchfile ...


This is probably an easy question for most of you ;-)

Thanks for your help!

Dimo

Matt Williamson

unread,
Mar 16, 2007, 3:20:50 PM3/16/07
to
> Hi folks,
> just a newbie-question about using variables:
>
> How can I use the result of a dsquery user-statement in a variable in
> dos-batchfile?
> I'd like to read the DN of an AD-User by passing
> dsquery user
> OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla -samid
> qx64209
> and use the result
> "CN=Dimo
> Tabken,OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla"
> as a variable called UserDN.
> Unfortunately I don't have an idea how to do this ...
> set UserDN=dsquery user
> OU=User,OU=SF_D,OU=Accounts,DC=Domain,DC=company,DC=blablabla -samid
> qx64209
> would probably work in VB / VBA ... but it doesn't in my batchfile ...

Well, I can't test it because I haven't switched to AD yet but this should
give you something to try. Obviously, you need to use the whole dsquery
command between the parens.

For /f "tokens=*" %%a in ('dsquery user...') do set UserDN=%%a

HTH

Matt

--
Posted via a free Usenet account from http://www.teranews.com

0 new messages