.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to query the Active directory using SQL Server 2005

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :Sql Server
Hi, I am trying to query Active server from Sql Server 2005 and getting error I used following script to create link server EXEC sp_addlinkedserver 'ADSI3', 'Active Directory Services 111', 'ADSDSOObject', 'adsdatasource' and then trying to connect using following statement SELECT   * FROM OpenQuery(ADSI, 'SELECT * FROM 'LDAP://DC=local.mycompany.ca' WHERE objectCategory='User' ') and getting following error An error occurred while preparing the query "SELECT * FROM 'LDAP://DC=local.resound.ca' WHERE objectCategory='User' " for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI". Please let me know if you know How to query the Active directory using SQL Server 2005 Thanks, Raj    Dreaming a world without any war in anywhere

View Complete Post

More Related Resource Links

Outputting an Active Directory Query

This may be something really simple, but how do I output this code: private DirectoryEntry GetDirectoryObject() { DirectoryEntry oDE; oDE = new DirectoryEntry("LDAP://test.test.test/DC=test,DC=test,DC=test", "username", "password", AuthenticationTypes.Secure); return oDE; } private DirectoryEntry GetAllUsers() { DirectoryEntry de = GetDirectoryObject(); DirectorySearcher deSearch = new DirectorySearcher(); deSearch.SearchRoot = de; deSearch.Filter = "(&(objectClass=user))"; deSearch.SearchScope = SearchScope.Subtree; SearchResult results = deSearch.FindOne(); if (!(results == null)) { de = new DirectoryEntry(results.Path, "username", "password", AuthenticationTypes.Secure); return de; } else { return null; } } to a list, I'm trying to create a list of company phone numbers for out intranet site based on AD so if anyone could tell me how to query that too that would be great :)Many thanks,    private DirectoryEntry GetDirectoryObject()     {         DirectoryEntry oDE;         oDE = new DirectoryEntry("LDAP://test.test.test/DC=test,DC=test,DC=test&quo

Sql Server 2005 ( remove header information from query output file "Job 'bustd_Daily_Query_Output_1

Dear All,I have scheduled job for querying output & asve it into particuler folder....but in the top of file i getting the message like "Job 'bustd_Daily_Query_Output_13July09' : Step 1, 'Query1' : Began Executing 2009-07-13 16:32:06"I want to remove this & want output in txt file format without above header....RegardsRavendra Cindia

Is it possible to configure sharepoint to use active directory service configured in another server

I installed sharepoint in a computer which is not configured as a domain,I want it to use the active directory services in the domain which is another computer

Query Active Directory for accounts missing email addresses

How I can query Active Directory for accounts missing email address.  What is the syntax for this from a .Net application.  Does anyone have sample code for doing this?  I am also looking to query AD for GetCustomersWithInvalidEmailAddresses. Thanks so much.... 

Issues reinstalling a Second Node (Active/Passive) SQL Server 2005 Lustering

We originally had an Active /Active-Passive Node Cluster; (SQLCLUSTER1 (S1) and SQLCLUSTER2 (S2). After a client who needed access to SQLCLUSTER2 was unable to connect, I discovered that the TCP Ports somehow got corrupted.  I couldn’t find a 1433 port. So, I obviously had to do a reinstall.  NOTE: S1 contains the R and S drives (SANs).  S2 contained the T and U drives (SANs as well).   I used the following site to check my install: http://www.sql-server-performance.com/articles/clustering/cluster_server_2003_p1.aspx  By: Brad McGehee   While installing a failover (active/passive node) everything was going well, until I got to the Cluster Group Selection screen.  Under Available cluster groups showed: Cluster Mgmt Group (this Group contains the Quorum Q drive). Under the Unavailable cluster groups showed:  SQL Cluster Group (SQLCLUSTER1) – Already contains a SQL Virtual Server and the next one, SQLCLUSTER2 – Already contains a SQL Virtual Server. Under Data files:  I tried to place the data on the T: drive and I received an error stating that I cannot put data on the same drive as the Quorum drive.   Prior to the reinstall of S2, I deleted/removed all SQL Server data on S2.  Perhaps, this is where my problem may lie. So, my first question is, do I need to reinstall S2? My second question is, could there be

Upgrading .net framework and server effect active directory


Hi All,

I want to ask some questions that i doubt.

Now currently, our project using active directory on vb.net 1.1 and server 2003. We will be upgrade to vb.net 3.5 and server 2008.

In this case, 1. We convert all vb.net 1.1 application to vb.net 3.5 and run on server 2003.

Then later on, 2. Our server will upgrade to server 2003 to server 2008.

I would linke to know after doing above two phase will effect on Active Directory code setting in our program.

Can I conver to 1 to 1 withut changing anything in vb.net and server?

Tracing of query in sql server 2005

hi friends,

Is it possible that while a query is running in sql server 2005 but cann't be possible to trace it in profiler or in activity monitor.

Thanks in Advance

slective order by in sql server 2005 query

except ascending or decending can we define our own choice of order by, like if i set order by hour it display 0(zero) first, but if time start form 1800 then how to display 18 first then 19 then 20 then so on to 5am can any body help in sql 2005 server

Windows Server 2008 32 and 64bit and Active Directory


By any chance do you if it is recommended to have Sharepoint 2010 and
Active Directory on the same windows 2008 server? Or they have to be on separate servers?

Also, do you know if Windows 2008 32 bit have any conflict communicating
with Windows server 2008 64bit?




select query sql server 2005


i have three table

1)    tbl_pages              primary key column is  (intPk_PageID)

2)   tbl_pagecontents   foreign key colum (intPk_PageContentID) reference with tbl_pages

3)   tbl_banners           foreign key colum  (intFk_pageid) reference with tbl_pages

select * from tbl_pages
intPk_PageID   vcr_PageTitle    vcr_PageUrl         int_PageStatus
1                      Contact Us          contactus.aspx             1
2                      News                   news.aspx       

how to store query string in sql server 2005


Hi all,


how to store query string in sql server 20005 

[Sql Server 2005] Need help to query with joins


Hi all :)

I hope anyone save me from madness ...

here is my query

                      t1.date, t1.employeeID, t2.name AS customer,

                     t3.description AS service, t4.total as amount

FROM            Trg_EmployeeCalendar AS t1 LEFT OUTER JOIN
                    EmployeeJobs AS t4 ON t1.employeeID = t4.employeeID AND t1.date = t4.date LEFT OUTER JOIN
                    Customers AS t2 ON t2.id_location = t4.locationID LEFT OUTER JOIN
                    ServiceCategory AS t3 ON t3.id_service = t4.serviceID LEFT OUTER JOIN

With this query, if an employee has two jobs in different l

Executing XML query from SQL 2005 pointing to SQL 2000 server

Occurs with root command.
Executed as user: DOMAIN\SERVER01. Error Code: 0  Error Source= ADODB.Command  Error Description: Item cannot be found in the collection corresponding to the requested name or ordinal.    Error on Line 18.  The step failed.
Executed as user: DOMAIN\SERVER01. Error Code: 0  Error Source= Microsoft OLE DB Provider for SQL Server  Error Description: Line 1: Incorrect syntax near 'ROOT'.    Error on Line 20.  The step failed.
Dim oCmd, sSQL, oDom
   Set oDom = CreateObject("Microsoft.XMLDOM")
   Set oCmd = CreateObject("ADODB.Command")
  oCmd.ActiveConnection ="Driver={SQL Native Client};Database=Validation;Server=server1;Uid=sa;Pwd=;"
   sSQL = "<?xml version=""1.0"" ?>"
   sSQL = sSQL &

Reading Active Directory in SQL 2005


I would like to read active directory and update the email and NTUserID Columns of Employee Table.

Which method can I use in SQL 2005 to read the active directory?



How to write a SQL query to present values horizontally sql server 2005

Suppose I have one table called Jobs:

    [JOBID] [int] IDENTITY(1,1) NOT NULL,
    [PARTDESC] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [OrderPlacedBy] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [SpecialistName] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Priority] [int] NOT NULL,
    [Symptoms] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [CustomerNotes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [ShopNotes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [JobType] [nvarchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [JobState] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL,
    [JobAddedDate] [datetime] NOT NULL,
    [JobStartedDate] [datetime] NULL,
    [JobFinishedDate] [datetime] NULL,
    [JobShippedDate] [datetime] NULL,
    [RecievedDate] [datetime] NULL

I want to see the specialist name and his jobs IDs horizontally.

ANA 201,502,605,701,774
BEN 102,103,051
JEN 705,401,402,509,409,408

A s

Running SQL query to get pwdlastset value from Active Directory


Hi there,

I running an SQL query to get records from Active Directory field called PwdLastSet. And I get the result as:


How do I convert this numbers like this to display as date. I am running this query ton SQL Server 2005.

What convert function can we use to display the values as date in SQL

Kindly reply.

All comments and feedbacks are welcomed.

Thank you! :)


Help converting an Acesss SQL query to SQL Server 2005 query


I am trying to convert this microsoft access query to sql 2005 query. Thank you for taking the time to look.

(This is taking a markup field (MultiplierCode) with a value like 1.45/1.5 and splitting into 2 numbers (1.45 would be the regular markup (based on the pay rate) and the 1.5 would be the overtime markup of the Bill Rate. Then updating orders and assignments based on that.)

UPDATE Order_Root INNER JOIN assignmentroot ON Order_Root.OrderID = assignmentroot.OrderID SET Order_Root.Bill = [order_root]![pay]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1)), Order_Root.OBillRate = [order_root]![pay]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1))*(Right([order_root]![MultiplierCode],Len([order_root]![MultiplierCode])-InStr(1,[order_root]![MultiplierCode],"/"))), Order_Root.DBillRate = [pay]*(Left([order_root]![MultiplierCode],(Len(Left("order_root]![[MultiplierCode]",InStr([order_root]![MultiplierCode],"/"))))-1)*2), assignmentroot.BillRate = [payrate]*(Left([order_root]![MultiplierCode],(Len(Left([order_root]![MultiplierCode],InStr([order_root]![MultiplierCode],"/"))))-1)), assignmentroot.OBillRate = [payrate]*(Left([order_root]![MultiplierCo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend