Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Active Directory > Active Directory Search for attribute

Reply
Thread Tools Display Modes

Active Directory Search for attribute

 
 
Elvis
Guest
Posts: n/a

 
      12-07-2009
Hi,

Does anyone have a custom Quesry for Active Directory that is able to find a
"null" value for any attributes within AD. We are looking to use an existing
Active Directory Attribute field but need to be certain that it is not being
used. Is there a way to seach AD to verify which attributes are not being
used by anyone?

Thanks

Elvis
 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      12-07-2009


"Elvis" <> wrote in message
news:B26AAA71-046A-4EC4-A11E-...
> Hi,
>
> Does anyone have a custom Quesry for Active Directory that is able to find
> a
> "null" value for any attributes within AD. We are looking to use an
> existing
> Active Directory Attribute field but need to be certain that it is not
> being
> used. Is there a way to seach AD to verify which attributes are not being
> used by anyone?
>
> Thanks
>
> Elvis


I use ADO in VBScript programs to query AD. See this link for details:

http://www.rlmueller.net/ADOSearchTips.htm

Using the syntax and variables from the link, you can filter on objects
where a specified attribute has or has not been assigned a value. For
example, the filter for all users where the employeeID attribute has a value
would be:

strFilter = "(&(objectCategory=person)(objectClass=user(employ eeID=*))"

A VBScript program to find all users with a value assigned to employeeID
could be similar to below:
===========
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strDN, strName

' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"

' Filter on all users with value assigned to employeeID attribute.
strFilter = "(&(objectCategory=person)(objectClass=user)(emplo yeeID=*))"

' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,sAMAccountName"

' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

' Run the query.
Set adoRecordset = adoCommand.Execute

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Retrieve values.
strDN = adoRecordset.Fields("distinguishedName").Value
strName = adoRecordset.Fields("sAMAccountName").Value
Wscript.Echo strDN & " (" & strName & ")"
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close
===========
You can also use the same filter with adfind. For example:

adfind -default -f
"(&(objectCategory=person)(objectClass=user)(emplo yeeID=*))" sAMAccountName

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
Florian Frommherz [MVP]
Guest
Posts: n/a

 
      12-08-2009

Howdie!

Elvis schrieb:
> Does anyone have a custom Quesry for Active Directory that is able to find a
> "null" value for any attributes within AD. We are looking to use an existing
> Active Directory Attribute field but need to be certain that it is not being
> used. Is there a way to seach AD to verify which attributes are not being
> used by anyone?


You probably want to return all objects that have a value set to an
attribute. If the query does not return any objects, chances are the
attribute isn't used.

The advice you got from Richard is great - checking with the start (*)
operator gives you all objects that have a certain value set for the
attribute:

(someAttribute=*)

If you're going to search an empty attribute for users only (cause you
don't care about computers or the data you want to put into that empty
attribute isn't applicable to computers, you might want to filter down
further:

(&(objectClass=user)(objectCategory=person)(someAt tribute=*))

Besides finding a good candidate for custom provisioning of data, you
might want to think about making sure how data is
(a) entered there, as ADUaC isn't as flexible - and WHO manages the data
(b) secured against manual tempering in case it has to be read-only to a
couple of candidates (note that objects themselves have permission to
change most of their own attributes)
(c) something you to be replicated to Global Catalogs
(d) good to be replicated to RODCs.

Cheers,
Florian
--
Microsoft MVP - Group Policy
eMail: prename [at] frickelsoft [dot] net.
blog: http://www.frickelsoft.net/blog.
ANY advice you get on the Newsgroups should be tested thoroughly in your
lab.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active directory adn Wins server Daniele Active Directory 7 12-01-2009 03:05 PM
Active directory indices rebuilding... John Windows Small Business Server 0 11-17-2009 04:13 AM
Active Directory with IPv6 Jorge Active Directory 4 11-12-2009 09:51 PM
Set default search beheviour Dave21 Windows Vista File Management 1 09-25-2007 09:03 PM
Is Windows Vista index-based full-text search powerful enough? Peter Frank Windows Vista File Management 47 03-23-2007 06:54 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59