views:

33

answers:

0

I am using Windows Authentication in asp.net every thing is ok in local but when deploying on different system of same domain then its working getting error in this line SearchResult userObject = adSearcher.FindOne();

Error

system.runtime.interopservice.comException

My code is

    WindowsIdentity winId = id as WindowsIdentity;
    if (id == null)
    {
        Console.WriteLine("Identity is not a windows identity");
        return;
    }

    string userInQuestion = winId.Name.Split('\\')[1];
    string myDomain = winId.Name.Split('\\')[0];                       
    DirectoryEntry entry = new DirectoryEntry("LDAP://" + myDomain);
    DirectorySearcher adSearcher = new DirectorySearcher(entry);

    adSearcher.SearchScope = SearchScope.Subtree;
    adSearcher.Filter = "(&(objectClass=user)(samaccountname=" + userInQuestion + "))";
    SearchResult userObject = adSearcher.FindOne();
    StringBuilder data =new StringBuilder();

Error page: link text