Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
m trying to take information from the Active Directory and display it to text box.
When am running it from localhost it does work but when i host it to a server and run it, it give me this error "LDAP server is unavailable"

Here is my code

C#
Session["name"] = txtnameuser2nd.Text;

        PrincipalContext context = new PrincipalContext(ContextType.Domain, "NMMU");
        UserPrincipal user = UserPrincipal.FindByIdentity(context, Session["name"].ToString());
        txtname2nd.Text = user.GivenName.ToString();
        txtlastname2nd.Text = user.Surname.ToString();
Posted

I finally found the solution.

C#
Session["name"] = txtnameuser2nd.Text;
 
        PrincipalContext context = new PrincipalContext(ContextType.Domain, "nmmu.ac.za");
        UserPrincipal user = UserPrincipal.FindByIdentity(context, Session["name"].ToString());
        txtname2nd.Text = user.GivenName.ToString();
        txtlastname2nd.Text = user.Surname.ToString();


i ddnt give the user full access to the domain server, so i solved it by including the correct name of the domain server. nmmu.ac.za instead of nmmu. nmmu was not fully defined

:-)
 
Share this answer
 
v2
It looks like more people had the same problem, probably one of the links[^] can help you.
 
Share this answer
 
It looks like more people had the same problem, probably one of the links[^] can help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900