Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

System.DirectoryServices Unknown error (0x80005000)

$
0
0

Hello all,

This is my first post so I apologize if my netiquette is slightly off.  I have several applications that connect to a remote LDAP server for authentication.  These applications all worked fine on my previous laptop configurations (most recently Windows 7 / IIS 7.5).  I just got a new machine with Windows 8 / IIS 8 and I am having a problem communicating with the LDAP server.

This is how my code works:

1. Bind to the LDAP for authentication - THIS WORKS FINE

2. Retrieve the properties for the LDAP user from the LDAP server - THIS WORKS FINE

3. Loop through the properties and populate a business object - the first few iterations work fine but at some point while iterating through the LDAP properties, an 'Unknown error' is thrown.  No additional information is provided.

Here is the relevant code:

string ld = "";
                    if (!ldap_server.Equals(""))
                    { ld = ldap_server; }
                    else
                    { ld = ConfigurationManager.AppSettings["LDAP_SERVER"]; }
                    DirectoryEntry de = new DirectoryEntry(ld);
                    de.Username = ConfigurationManager.AppSettings["UserDn"].Replace("[user]", userId);
                    de.Password = password;

                    de.AuthenticationType = AuthenticationTypes.SecureSocketsLayer | AuthenticationTypes.FastBind;

                    
                    DirectorySearcher src = new DirectorySearcher(de);
                    src.SearchRoot = de;
                    src.SearchScope = SearchScope.Subtree;
                    src.Filter = "(uid=" + searchUserId + ")";

                    SearchResult result = src.FindOne();
                    
                        DirectoryEntry dirEntry = result.GetDirectoryEntry();

                        foreach (string key in dirEntry.Properties.PropertyNames)
                        {
                            //Each property contains a collection of its own that may contain multiple values
                            foreach (object propVal in dirEntry.Properties[key])
                            {
                                //Response.Write("<!--" + key + " = " + propVal + "//-->\n");

                                //set up the person object here
                                if (key.Equals("givenName"))
                                { name_first = (string)propVal; }
                                else if (key.Equals("sn"))
                                { name_last = (string)propVal; }
                                else if (key.Equals("telephoneNumber"))
                                { telephone = (string)propVal; }
                                else if (key.Equals("mail"))
                                { email = (string)propVal; }
                                else if (key.Equals("rulinkRutgersEduStaffDepartment"))
                                { dept = (string)propVal; }
                                else if (key.Equals("rulinkRutgersEduStaffLocation"))
                                { campus = (string)propVal; }
                                else if (key.Equals("postalAddress"))
                                { arrAddress = propVal.ToString().Split(new char[] { '$' }); }
                                else if (key.Equals("rutgersEduIID"))
                                { iid = (string)propVal; }
                                else if (key.Equals("rutgersEduRUID"))
                                { rutgers_id = Convert.ToInt32(propVal).ToString(); }
                                else if (key.Equals("employeeType"))
                                { employeeType.Add((string)propVal); }
                                else if (key.Equals("title"))
                                { title = (string)propVal; }

                            }
                        }

This is the exception being thrown:

Message    "Unknown error (0x8000500c)"    string
Source    "System.DirectoryServices"    string
StackTrace   "at System.DirectoryServices.PropertyValueCollection.PopulateList()\r\n   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)\r\n   at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)\r\n   at Rutgers.Ugadm.Rist.CoreLib.Person.populatePersonObjectFromLDAPAdmin(String userId, String password, String searchUserId) in c:\\work\\dotNet\\CoreLib\\users\\Person.cs:line 613"    string

Again - I can connect/bind to the LDAP server so it does not appear to be a security issue.  The iteration through the foreach loops also works fine as the first two or three items populate properly.  After that it throws the exception regardless of the property being retrieve.

This code has worked fine for me for years.  The only change I made was the migration to Windows 8 so I believe there is something that is new in IIS causing this to happen.

Any thoughts/ideas would be appreciated.  I have been searching for answers on this and I am kind of at a loss.

Thanks,
Daniel




Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>