locked
Different result between Debug and Publish RRS feed

  • Question

  • User-1144112885 posted

     Hi:

    The result of following code is different between Debug and Publish.

                string filter = string.Format("(|((SAMAccountName={0})(displayName={0})(distinguishedName={0})))", key);
                string path = ConfigurationManager.ConnectionStrings["Ldap"].ConnectionString;
    
                //  to use this constructor will generate exception in Publish, but Debug will not.
                DirectoryEntry entry = new DirectoryEntry(path);
                
                // use this line will not generate exception in Publish and Debug.
                //DirectoryEntry entry = new DirectoryEntry(path,"username","password");
    
                DirectorySearcher searcher = new DirectorySearcher(entry, filter);
                SearchResult result = searcher.FindOne();


     

    Wednesday, August 5, 2009 1:49 AM

Answers

  • User-2009597737 posted

    To start with. The sAmaAccountName and the DisplayName usually do not have the same value.

    You get exception in publish as you do not have credentials to connect to the LDAP. It most probably uses the IIS worker process. Works in your debug as it most likely uses your credentials. Normally all AD accounts can read the  AD tree. When you explictly set the permissions, it works.

    What is the result you are expecting ? and is the LDAP connection string same form publish and debug?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 5, 2009 11:27 AM

All replies

  • User156948580 posted

    Isn't there problem (e.g. difference) while runing under local IIS and Visual Studio debug server?

    Have you checked impersonation settings?

    Wednesday, August 5, 2009 9:24 AM
  • User-2009597737 posted

    To start with. The sAmaAccountName and the DisplayName usually do not have the same value.

    You get exception in publish as you do not have credentials to connect to the LDAP. It most probably uses the IIS worker process. Works in your debug as it most likely uses your credentials. Normally all AD accounts can read the  AD tree. When you explictly set the permissions, it works.

    What is the result you are expecting ? and is the LDAP connection string same form publish and debug?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 5, 2009 11:27 AM