﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Query AD (Active Directory) / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 02:51:46 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>Thank you for that Randy.  It's always good to have the solution for others to find in the future.</description><pubDate>Mon, 08 Oct 2012 08:14:13 GMT</pubDate><dc:creator>Scott D. Jacobson</dc:creator></item><item><title>RE: Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>I exclude Disabled in a vb script that queries AD.Here’s the check for a user being disabled in AD:(userAccountControl:1.2.840.113556.1.4.803:=2)So to exclude use ([b]![/b]userAccountControl:1.2.840.113556.1.4.803:=2) in the filter:strFilter = "(&amp;(objectCategory=person)[b](!userAccountControl:1.2.840.113556.1.4.803:=2)[/b](objectClass=user)(memberOf=cn=CERUsers,ou=CER,ou=intranet applications,ou=groups,ou=khs,dc=myhouse,dc=org))"From the VB script:[code="plain"]' Open the output file for write access.Set objFile = objFSO.OpenTextFile(strFilePath, 2, True, 0)Set objRootDSE = GetObject("LDAP://RootDSE")strDNSDomain = objRootDSE.Get("defaultNamingContext")Set objCommand = CreateObject("ADODB.Command")Set objConnection = CreateObject("ADODB.Connection")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider","myhouse\mylogin","mypassword"objCommand.ActiveConnection = objConnectionstrBase = "&amp;lt;LDAP://" &amp; strDNSDomain &amp; "&amp;gt;"strFilter = "(&amp;(objectCategory=person)(!userAccountControl:1.2.840.113556.1.4.803:=2)(objectClass=user)(memberOf=cn=Distribution Group Corporate Management,ou=Mail Groups,ou=groups,ou=khs,dc=myhouse,dc=org))" strAttributes = "cn,displayName,mail,title,physicalDeliveryOfficeName"strQuery = strBase &amp; ";" &amp; strFilter &amp; ";" &amp; strAttributes &amp; ";subtree"objCommand.CommandText = strQueryobjCommand.Properties("Page Size") = 100objCommand.Properties("Timeout") = 30objCommand.Properties("Cache Results") = FalseSet objRecordSet = objCommand.Execute[/code]</description><pubDate>Thu, 04 Oct 2012 13:59:32 GMT</pubDate><dc:creator>Randy Doub</dc:creator></item><item><title>RE: Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>Any chance you can share what the attribute was called? As Lowell mentioned he didn't find anything obvious.  I did a quick skim through but the list is quite long.</description><pubDate>Thu, 04 Oct 2012 08:01:47 GMT</pubDate><dc:creator>Scott D. Jacobson</dc:creator></item><item><title>RE: Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>Thanks, that was very helpful.</description><pubDate>Thu, 04 Oct 2012 06:29:15 GMT</pubDate><dc:creator>kd11</dc:creator></item><item><title>RE: Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>this site has the most comprehensive list of attributes you can query that i've ever tripped over:[b][url]http://www.rlmueller.net/UserAttributes.htm[/url][/b]specifically, his excel spreadsheet has a ton of stuff:[b][url]http://www.rlmueller.net/References/Schema.xls[/url][/b]i searched for "locked" and "enabled" and "disabled", and didn't see anything that seemed to me to be  specific to a useryou may have a better idea on what to search for than me.</description><pubDate>Wed, 03 Oct 2012 11:55:21 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Query AD (Active Directory)</title><link>http://www.sqlservercentral.com/Forums/Topic1367893-391-1.aspx</link><description>I know you can query AD for logins,email,location but if I want to know if the users are active or not, can I pull that as well. I'm not seeing it in the container if so.</description><pubDate>Wed, 03 Oct 2012 11:39:59 GMT</pubDate><dc:creator>kd11</dc:creator></item></channel></rss>