WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Disabled User Accounts on the Domain


Question:

Currently using the following to see make a list of disabled accounts.
AddExtender("WWADS34I.DLL")

Output=FileOpen(Strcat(Environment("Temp"),"\DisabledUsers.txt"),"WRITE")


BoxOpen("Processing","Processing, Please Wait")
search=DsFindPath("LDAP://DOMAIN", "(ObjectClass=User)")
Count=ItemCount(search,@TAB)
For x = 1 to Count
Item=ItemExtract(x,search,@TAB)
BoxText(Item)
a=dsGetProperty(Item, "userAccountControl")
If a & 2
FileWrite(Output,Item)
EndIf
Next

FileClose(Output)
Run("Notepad.txt",Output)
The question, how / if I can make DsFindPath do something like the following so I don't have to go through every object:
search=DsFindPath("LDAP://DOMAIN", "(&(ObjectClass=User)(userAccountControl = & 2))") 

Answer:

http://support.microsoft.com/?kbid=269181 Read the "Query Active Directory By Using a Bitwise Filter" section .

Example:

search=DsFindPath("LDAP://DOMAIN", "(&(&(ObjectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))(!(ObjectClass=Computer)))") 
Note: You can speed up your search by using the "objectCategory" property. For example, (&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=2))....*

ObjectCategory contains the predominate class of an object and is indexed by AD, so it is faster than using ObjectClass. You will even get a performance boost by using both ObjectCategory and ObjectClass in a search specification.

*Note: the above example search filter has not been tested.

User Reply:

Tried ObjectCategory with some very bad results. In some cases it was returning nothing or the exact opposite of the search. Without changing the search string and changing it to ObjectClass it works fine. Might be something with our AD domain... dunno... Go figure...

Answer:

Without seeing your filter string it is impossible to say, but objectCategory is definitly the way to go. Read the following: http://msdn.microsoft.com/library/shared/deeptree/asp/rightframe.asp?dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/adsi/adsi/objectcategory_vs__objectclass.asp?frame=true&hidetoc=false

or

http://msdn.microsoft.com/library/shared/deeptree/asp/rightframe.asp?dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/ad/ad/finding_objects_by_class.asp?frame=true&hidetoc=false I suspect you have a problem in the logic of your search filter or someone has been mucking about with your directory schema without knowing exactly what they were doing.


Article ID:   W16317
File Created: 2005:02:18:12:19:46
Last Updated: 2005:02:18:12:19:46