Examples of querying the Active Directory: ========================================== -- Modify the following queries to point to an OU in your Active Directory hierarchy -- Add a linked server for the Active Directory exec sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADsDSOObject', 'adsdatasource' -- Query for a list of Contact entries in an OU using the LDAP query dialect select convert(varchar(50), [Name]) as FullName, convert(varchar(50), Title) as Title from openquery(ADSI, '; (objectClass=Contact);Name,Title;subtree') -- Query for a list of User entries in an OU using the SQL query dialect select convert(varchar(50), [Name]) as FullName, convert(varchar(50), Title) as Title, convert(varchar(50), TelephoneNumber) as PhoneNumber from openquery(ADSI, 'select Name, Title, TelephoneNumber from ''LDAP://OU=Directors,OU=Atlanta,OU=Intellinet,DC=vizability,DC=intellinet,DC=com'' where objectClass = ''User''') -- Query for a list of Group entries in an OU using the SQL query dialect select convert(varchar(50), [Name]) as GroupName, convert(varchar(50), [Description]) GroupDescription from openquery(ADSI, 'select Name, Description from ''LDAP://OU=VizAbility Groups,DC=vizability,DC=intellinet,DC=com'' where objectClass = ''Group''') Examples for querying the Public Folder store in Exchange 2000: =============================================================== -- Modify the following queries to point to your Exchange 2000 PF hierarchy -- Add a linked server for the Exchange 2000 PF store -- Note that the datasource named uses the Exchange 2000 domain name, not a server name exec sp_addlinkedserver 'E2K_PF', 'Exchange OLE DB provider', 'exoledb.DataSource.1', 'file:\\.\backofficestorage\vizability.intellinet.com\public folders' -- Query for a list of Contact entries in a PF select convert(varchar(50), "urn:schemas:contacts:sn") as LastName, convert(varchar(50), "urn:schemas:contacts:givenName") as FirstName from openquery(E2K_PF, 'select "urn:schemas:contacts:sn", "urn:schemas:contacts:givenName" from scope(''shallow traversal of ".\Intellinet\Atlanta\Atlanta Contacts"'')') -- Query for a list of appointment Calendar entries in a PF select convert(varchar(50), "urn:schemas:httpmail:subject") as Subject, convert(varchar(50), "urn:schemas:calendar:dtstart") as StartDate from openquery(E2K_PF, 'select "urn:schemas:httpmail:subject", "urn:schemas:calendar:dtstart" from scope(''shallow traversal of ".\Intellinet\Atlanta\Atlanta Events"'') where "urn:schemas:calendar:alldayevent" = TRUE') order by Subject, StartDate -- QUery for a list of all-day-event Calendar entries in a PF select convert(varchar(50), "urn:schemas:httpmail:subject") as Subject, convert(varchar(50), "urn:schemas:calendar:dtstart") as StartDate from openquery(E2K_PF, 'select "urn:schemas:httpmail:subject", "urn:schemas:calendar:dtstart" from scope(''shallow traversal of ".\Intellinet\Atlanta\Atlanta Events"'') where "urn:schemas:calendar:alldayevent" = FALSE') order by Subject, StartDate Examples for querying a specific mailbox in Exchange 2000: ========================================================== -- Modify the following queries to point to a specific Exchange 2000 mailbox -- Add a linked server for the Exchange 2000 mailbox -- Note that the login you use to query with must have access to this mailbox's folders exec sp_addlinkedserver 'E2K_Administrator', 'Exchange OLE DB provider', 'exoledb.DataSource.1', 'file:\\.\backofficestorage\vizability.intellinet.com\MBX\Administrator' -- Query for a list of appointment Calendar entries in the mailbox select convert(varchar(50), "urn:schemas:httpmail:subject") as AppointmentName, convert(varchar(50), "urn:schemas:calendar:dtstart") as StartDate from openquery(E2K_Administrator, 'select "urn:schemas:httpmail:subject", "urn:schemas:calendar:dtstart" from scope(''shallow traversal of ".\Calendar"'') where "urn:schemas:calendar:alldayevent" = FALSE')