473,394 Members | 1,718 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,394 software developers and data experts.

ADSI Query fails with unspecified error

Hello All
I'm trying this to filter group users bu tI keep getting an unspecified
error when invoking FindOne method.

Any help is greatly appreciated.

public static DirectoryEntry GetDirectoryRoot()
{
return new DirectoryEntry("LDAP://RootDSE");
}

public static string DefaultNamingCtx
{
get{
string defCtx=null;
using(DirectoryEntry rootDe = GetDirectoryRoot())
{
defCtx = rootDe.Properties["defaultNamingContext"][0].ToString();
}
return defCtx;
}
}

public static void GetGroupUsers(string groupName, ADSet dSet)
{
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = new DirectoryEntry(DefaultNamingCtx);
deSearch.Filter = string.Format("(&(objectClass=group)(cn={0}))",
groupName);
try
{
SearchResult result = deSearch.FindOne(); //***This keeps failing ***
}
catch(COMException ex)
{}

May 1 '06 #1
4 2974
deSearch.SearchRoot = new DirectoryEntry("LDAP://" + defCtx);

Willy.

"sjoshi" <sj****@ingr.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
| Hello All
| I'm trying this to filter group users bu tI keep getting an unspecified
| error when invoking FindOne method.
|
| Any help is greatly appreciated.
|
| public static DirectoryEntry GetDirectoryRoot()
| {
| return new DirectoryEntry("LDAP://RootDSE");
| }
|
| public static string DefaultNamingCtx
| {
| get{
| string defCtx=null;
| using(DirectoryEntry rootDe = GetDirectoryRoot())
| {
| defCtx = rootDe.Properties["defaultNamingContext"][0].ToString();
| }
| return defCtx;
| }
| }
|
| public static void GetGroupUsers(string groupName, ADSet dSet)
| {
| DirectorySearcher deSearch = new DirectorySearcher();
| deSearch.SearchRoot = new DirectoryEntry(DefaultNamingCtx);
| deSearch.Filter = string.Format("(&(objectClass=group)(cn={0}))",
| groupName);
| try
| {
| SearchResult result = deSearch.FindOne(); //***This keeps failing ***
| }
| catch(COMException ex)
| {}
|
May 1 '06 #2
Thanks...that was dumb of me to miss it.

rgds
Sunit

May 1 '06 #3
Hello,

Basically, I want my application to run only one instance at a time and pass
command line arguments to a running instance. I have all of this working, I
used the IPC Remoting channel and my program handles the command line
arguments well. However, after my program has been running for a little while
(say 5-10 minutes) the command line arguments no longer are passed, and
instead it causes a .NET Remoting exception claiming to have come across a
null reference.

So in my Program.cs file, I have something like this.

if (alreadyrunning)
{
IpcChannel ipcCh = new IpcChannel("MyProgram_" + username);
ChannelServices.RegisterChannel(ipcCh, false);

RemotingConfiguration.RegisterWellKnownServiceType (typeof(RemotingService),
"Remoting", WellKnownObjectMode.Singleton);
ISharedAssemblyInterface obj = (ISharedAssemblyInterface)
Activator.GetObject(typeof(ISharedAssemblyInterfac e), "ipc://MyProgram_" +
username + "/Remoting");
obj.RunFirstInstance(arguments);
}
else
{
ISharedAssemblyInterface obj = (ISharedAssemblyInterface)
Activator.GetObject(typeof(ISharedAssemblyInterfac e), "ipc://MyProgram_" +
username + "/Remoting");
obj.HandleCommandLineArgs(arguments);
}
Again, it all works for a short time, but stops working claiming a null
reference on the HandleCommandLineArgs method after a while. I'm guessing
that even though I specifify a Singleton instance that it somehow gets
garbage collected or a new RemotingService class generated (even though my
program is still running).

Thanks in advance,
mitch
May 2 '06 #4
IIRC if you have a remoted object, its remoting stubs will be garbage
collected if it gets no method calls for 5 minutes. To avoid this, you
need to manage the lifetime of the remoted object. Search for
'InitializeLifetimeService', and you'll find a lot of ways to manage
the lifetime.

May 2 '06 #5

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

Similar topics

2
by: Enigma Webmaster | last post by:
Hi All, We've written a couple of functions which, when run in VB6 work fine and allow AD users to be updated. When we include the code into an ASP Page and try and update a users information...
0
by: RCIC | last post by:
Trying to get a user's full name using ADSI. It works in our Win2000 Active Directory but fails when I try to get a user's full name from a trusted WinNT domain. The error is "Cannot create ActiveX...
1
by: netkev | last post by:
I added the microsoft terraserver wsdl(version 2) as a web reference to my c++ application(vs.net 2k3). When I attempt to execute the getAreaFromPT method, I get an 'unspecified error' HRRESULT. ...
1
by: James Schuler | last post by:
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...
1
by: Chris Smith | last post by:
I've just noticed in the regular profiling information from our web application that a particular query on a fairly small database is taking about 15 seconds. The query is generated from software...
14
by: Jonathan Smith | last post by:
I am trying to develop an app using ADSI. I have the following code: Dim ADSUser As IADsUser ADSUser = GetObject("LDAP://CN=jonsmith,CN=users,DC=domain,DC=com") ...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
1
by: zmunoz | last post by:
I am working on a script using ADSI via COM in PHP. The script works for the most part when I query a user using the following function: function passwordExpires($userDN) { $comLDAP = new...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.