Jeevan Bhatt
Jeevan Bhatt

Reputation: 6101

why I am geting this error: System.Runtime.interopservice.ComException on windows Authentication

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

Upvotes: 1

Views: 341

Answers (2)

sivakumar
sivakumar

Reputation: 1

  Dim Connection As New ADODB.Connection
     Connection.Open(ConnectionString)
     Dim Insname As String
     Dim postname As String

Upvotes: 0

SGarratt
SGarratt

Reputation: 1004

From your error page, it's failing on the directory Bind. Does the app pool on the new machine have authority to query AD?

Upvotes: 1

Related Questions