473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Openquery and ADSI Problem

I am trying to run a query in an ASP.NET application against Active Directory
using a linked server (ADSI) in SQL Server 2000. The query runs without any
problems in Query Analyzer:

SELECT
sAMAccountName
FROM
OPENQUERY
(
ADSI,
'
SELECT
sAMAccountName
FROM
''LDAP://ADSERVER/ DC=ourdomain,DC=com''
WHERE
MemberOf=''cn=GroupName ,OU=ourOUname,DC=ourdomain,DC=com'' AND
sAMAccountName=''username''
'
);

The query will simply return a username if that user belongs to the
specified group. Once again, this works fine in Query Analyzer, but it does
not return any results in my ASP.NET application. I am using SQLConnection,
SQLCommand, and SQLDataReader objects. I have also tried this with generic
odbc objects, but to no avail.

I have found that the query executes in ASP.NET if I remove the MemberOf
section of the WHERE clause in the query.

Has anyone come across something like this before? Any help would be
appreciated.

Many Thanks,
Jim
Nov 18 '05 #1
1 2756
Sometimes these types of problems (works in XYZ program but not from
ASP.NET) arise because the ASPNET account does not have the same
permissions as the user running XYZ program. Are you connecting to the
database as the ASPNET account?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 29 Oct 2004 10:05:03 -0700, "James Schuler" <James
Sc*****@discussions.microsoft.com> wrote:
I am trying to run a query in an ASP.NET application against Active Directory
using a linked server (ADSI) in SQL Server 2000. The query runs without any
problems in Query Analyzer:

SELECT
sAMAccountName
FROM
OPENQUERY
(
ADSI,
'
SELECT
sAMAccountName
FROM
''LDAP://ADSERVER/ DC=ourdomain,DC=com''
WHERE
MemberOf=''cn=GroupName ,OU=ourOUname,DC=ourdomain,DC=com'' AND
sAMAccountName=''username''
'
);

The query will simply return a username if that user belongs to the
specified group. Once again, this works fine in Query Analyzer, but it does
not return any results in my ASP.NET application. I am using SQLConnection,
SQLCommand, and SQLDataReader objects. I have also tried this with generic
odbc objects, but to no avail.

I have found that the query executes in ASP.NET if I remove the MemberOf
section of the WHERE clause in the query.

Has anyone come across something like this before? Any help would be
appreciated.

Many Thanks,
Jim


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Akhlaq Khan | last post by:
we are developing an intranet application (web based) which needs to detect the logged in user ID of the user hitting the website. the intranet is huge and based on win2k active directory (around...
3
by: douglascfast | last post by:
Anyone, Is this possible? I am connecting to a TeraData server via MS SQL 8.0 using the OpenQuery statement. I need to pass a list of ever-changing deal numbers My list of numbers are...
0
by: noor | last post by:
Hi I'm working on linked server which uses db2oledb. When I tried simple select query it didn't ran because the queries condition was based on column having special character. Query was like that...
3
by: jj | last post by:
I've got a form button that fires off 3 queries but if the first query returns an error, I don't want the other two queries to happen. Example: first query runs an insert from a linked table but...
8
by: msnews.microsoft.com | last post by:
I have ADSI code that I can make work at the command line. I cannot in any way get it to work in asp.net. Even using Windows authentication, impersonation on, and providing the credentials...
2
by: savvy | last post by:
I'm performing a particular word Search in MS Word, Text, PDF docs and displaying the results through Index Server linked to SQL Server when it is matched. For which I'm using Openquery in the...
1
by: LittlePython | last post by:
I am a little confused on why I can not detect an object that does not exist with a try and except. If I understand ADSI correctly from what I have read you do not create these objects but rather...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
8
by: John | last post by:
Hi, gurus, How can I implement the following feature in C#: Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group") For Each objMember In objGroup.Members...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.