LDAP Error: Current security context is not associated with an ActiveDirectory domain or forest.

R

Raj

I am having a bad time with LDAP. I even bought a book, it has been
years since I did that but it did not have all the answers. I am
changing a web site to authenticate against Active Directory. They
need to be notified when the password is ready to expire, and they
also need to be able to change their own passwords, etc. The book
guides me to have a class that includes the following:

using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;

public class PasswordExpires
{
DomainPolicy policy;

const int UF_DONT_EXPIRE_PASSWD = 0x10000;

public PasswordExpires()
{
Domain domain = Domain.GetCurrentDomain(); <--
Error happens here
DirectoryEntry root = domain.GetDirectoryEntry();

using (domain)
using (root)
{
this.policy = new DomainPolicy(root);
}
}
.... more stuff ....
}

When I try to create a variable in vb.net (framework 2.0) of type
PasswordExpires ( the new class) it gives me an error: <Current
security context is not associated with an Active Directory domain or
forest.> Can anybody tell me if I am missing something like a
reference or library. I also tried doing a Domain.GetDomain
(myContext) and it said I had an invalid username or a bad password.
The problem is that I don't want the users to provide a password, if
they got into the domain when they logged in, they they should be
allowed in, but I do need to know who they are for logging, etc.

Any help will be appreciated. Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top