views:

65

answers:

1

Hi there,

I have a small C# solution used to check users credentials. It works fine for two of my teammates, but on my PC I get an exception.

The relevant code:

PrincipalContext context = new PrincipalContext(ContextType.Domain);
if (context.ValidateCredentials(System.Environment.UserDomainName + "\\" + usr, pwd))
     return true;
else
     return false;

And the exception is:

DirectoryOperationException, "The server cannot handle directory requests.".

I tried creating context with the explicit server name and the 636 port number, but this didn't help as well.

Any ideas?

Thanks, Noich

+1  A: 

Perhaps you need the hotfix?

And you are an Admin or the id that your service is running under is an Admin on your PC right?

I take it you already looked into this:

"You may receive a less than helpful DirectoryOperationException(“The server cannot handle directory requests.”) what isn’t quite so amusing about this is that it didn’t even try to communicate with the server. The solution was to add the port number to the server. So instead of passing “Server” to open the LdapConnection, I passed “server:636”. By the way, LDAPS is port 636 – rather than the 389 port used by LDAP."


Good point, I wouldn't expect that Win7/.NET 3.5 would need that patch. How about the info provided in this question:

JohnB
Maybe I got something wrong here, but the hotfix is for .Net2, and as I use 3.5, I don't have the .Net2 SP1 installed, which made the hotfix angry :)About the quote - I saw it, but thanks a lot anyway!
Noich
Ok, so it seems like the hotfix is not meant for win7 - SP1 can't be installed.
Noich
The problem was that this code was getting a server dynamically, and so received a server that wasn't running Windows 2008. When getting a specific server that did run Win2008, everything started working again. Hurray!
Noich
So, using that Hotfix, or using Windows Server 2008 is the solution to that exception.
JohnB