Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Getting ActiveDirectoryMembershipProvider to work decently

Last post 06-25-2008, 2:48 PM by dunnry. 3 replies.
Sort Posts: Previous Next
  •  06-23-2008, 4:07 AM 4001

    Getting ActiveDirectoryMembershipProvider to work decently

    Hello

    I'm currently working on a 3rd project using Active Directory integration. I used it in DotNetNuke modules before and never got it to work on our network, but miraculously it did work on the clients network, so no harm done.

    The problem is that I'm working on a tool for internal use now, and that the connection with OUR Active Directory should work this time. So I started off... I'm looking for the answer to my problems for over a week now and still haven't come up with anything that works. Last friday I was able to use 1 function (Membership.ValidateUser) without an error... but now even that function gives me an error. Funny thing is: I can use the ldp.exe tool on my computer, and it works... when I code something in my application, it doesn't. Strictly for the record, I am making a winforms tool, not a webform. So technically this post doesn't belong here, but I can't find a better place to ask about it, since the combination of a winforms with MembershipProvider seems to be as rare as the Loch Ness monster.

    Anyway, I'm using the LDAP string from the ldp.exe tool (LDAP://server.abc.local/DC=ABC,DC=LOCAL) and provide the same username/password (a domain admin) that I did with the ldp.exe tool. The error I can't seem to get around is "The server is not operational" or in some cases "Cannot establish a trusted relationship between the workstation and the primary domain". Currently I'm testing this with DirectoryEntry, just to see if I can at least get a connection, so that I can use that to fix the MembershipProvider.

    I also tried this:

                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

                bool bResult = Thread.CurrentPrincipal.IsInRole("Employees");

    Which was the first thing I got working, but somewhere during the weekend this also died :-( 

    Can anyone help me out with this?

    - Varcour

  •  06-23-2008, 5:09 PM 4010 in reply to 4001

    Re: Getting ActiveDirectoryMembershipProvider to work decently

    Is your workstation in the domain that you are testing against?  Is there something unusual about your network configuration that would have it not be able to resolve the domain name?

    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
  •  06-24-2008, 2:45 AM 4017 in reply to 4010

    Re: Getting ActiveDirectoryMembershipProvider to work decently

    The workstation is indeed in the domain.

    About the network configuration... well... I don't anything about that (an external company takes care of that),  but we did have these problems before. As I stated before: the ldp.exe tool DOES work, so I'm assuming it's something I forgot in the coding...

    Of course, if there are some specific things I could check, please let me know.

    -  Varcour
  •  06-25-2008, 2:48 PM 4037 in reply to 4017

    Re: Getting ActiveDirectoryMembershipProvider to work decently

    I am not sure on this one.  Do you have a stack trace so I can see where it is failing?  I wonder if the provider has a dependency on the HttpContext somewhere that might be causing some funky behavior...

    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
View as RSS news feed in XML