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

Discussion in 'ASP .Net' started by Raj, Jul 10, 2009.

  1. Raj

    Raj Guest

    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.
     
    Raj, Jul 10, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin
    Replies:
    3
    Views:
    4,026
    majied
    Jul 15, 2005
  2. Henning Truslew Gulliksen

    Cocoon/Forest pipeline for XML Schema documentation

    Henning Truslew Gulliksen, Sep 9, 2003, in forum: XML
    Replies:
    0
    Views:
    429
    Henning Truslew Gulliksen
    Sep 9, 2003
  3. SpaceMarine

    role-based security and ActiveDirectory

    SpaceMarine, May 28, 2009, in forum: ASP .Net
    Replies:
    18
    Views:
    2,073
    Joe Kaplan
    Jun 2, 2009
  4. David Thielen
    Replies:
    10
    Views:
    267
    Steven Cheng[MSFT]
    Jan 17, 2007
  5. SpaceMarine

    role-based security and ActiveDirectory

    SpaceMarine, May 28, 2009, in forum: ASP .Net Security
    Replies:
    18
    Views:
    1,193
    Joe Kaplan
    Jun 2, 2009
Loading...

Share This Page