Solved

DSQUERY help required

Posted on 2008-10-24
9
951 Views
Last Modified: 2012-05-05
Hi,

This code gets all users who do not have a manager.

DSQuery * -Filter "(&(sAMAccountType=805306368)(!manager=*))" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt

Can this be changed to query on a Specific OU rather than the whole domain.

REgards
Sharath
0
Comment
Question by:bsharath
  • 5
  • 4
9 Comments
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22799049
Yes it can basically you can have the dsquery select only the ou you want it would be something like this.

dsquery ou dc=mydom,dc=com and then your filter expression. You would need to enter the full path to your OU like the mydom.com above.
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22799119
Great site for all of you dsquery command line needs, also all the other DS commands as well.

http://www.geocities.com/rick_lively/MANUALS/COMMANDS/D/DSQUERY.HTM#ParameterOu
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819029
Can i have the more specific command on this. I get invalid command error.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 11

Author Comment

by:bsharath
ID: 22819030
Can i have the more specific command on this. I get invalid command error.
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 22819047
I will grab you some more info on this tomorrow. I dont have easy access to my AD right now. Once im back in the office Ill sort out the query.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819058
I get this

C:\>dsquery "OU=Named Accounts,OU=User Accounts,OU=IN,OU=Cou,DC=ment,DC=Group,DC=co,DC=uk -Filter "(&(sAMAccountType=805306368)(!manager=*)
)" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt
(!manager was unexpected at this time.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22819059
I get this

C:\>dsquery "OU=Named Accounts,OU=User Accounts,OU=IN,OU=Cou,DC=ment,DC=Group,DC=co,DC=uk -Filter "(&(sAMAccountType=805306368)(!manager=*)
)" -Attr sAMAccountName -Limit 0 >C:\UsersWithoutManager.txt
(!manager was unexpected at this time.
0
 
LVL 35

Accepted Solution

by:
Joseph Daly earned 500 total points
ID: 22821436
Ok so this is what I did this morning and it cmae out with the results I expected.

DSQUERY * "{start node path DC=blah DC=blah etc}" -filter "(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14))))(objectCategory=user)(!manager=*)))"
0
 
LVL 11

Author Comment

by:bsharath
ID: 22838687
Thank U...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question