PC Review


Reply
Thread Tools Rate Thread

ADSI Query fails with unspecified error

 
 
sjoshi
Guest
Posts: n/a
 
      1st May 2006
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)
{}

 
Reply With Quote
 
 
 
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      1st May 2006
deSearch.SearchRoot = new DirectoryEntry("LDAP://" + defCtx);

Willy.

"sjoshi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| 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)
| {}
|


 
Reply With Quote
 
sjoshi
Guest
Posts: n/a
 
      1st May 2006
Thanks...that was dumb of me to miss it.

rgds
Sunit

 
Reply With Quote
 
=?Utf-8?B?bWl0Y2g=?=
Guest
Posts: n/a
 
      2nd May 2006
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(ISharedAssemblyInterface), "ipc://MyProgram_" +
username + "/Remoting");
obj.RunFirstInstance(arguments);
}
else
{
ISharedAssemblyInterface obj = (ISharedAssemblyInterface)
Activator.GetObject(typeof(ISharedAssemblyInterface), "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
 
Reply With Quote
 
jnospamster@gmail.com
Guest
Posts: n/a
 
      2nd May 2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query regarding ADSI Edit tool Pete Halasovski Microsoft Windows 2000 Active Directory 6 9th Jan 2009 10:46 PM
ADSI query Concatenate? =?Utf-8?B?Sm9yZHk=?= Microsoft Dot NET 0 30th Mar 2006 04:02 PM
nativeobject fails with Winnt ADSI connection =?Utf-8?B?SmFzb24=?= Microsoft C# .NET 0 17th Aug 2004 02:03 PM
ADSI Query Adam Hafner Microsoft ADO .NET 4 26th Aug 2003 08:18 PM
ADSI/LDAP Query khaja shaik Microsoft ASP .NET 0 21st Jul 2003 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 AM.