Hi folks,
I am using asp.net core with web api and Novell LDAP library. Here is sample code as below:
LdapConnection conn = new LdapConnection(); Console.WriteLine("Connecting to:" + ldapHost); conn.Connect(ldapHost, ldapPort); conn.Bind(loginDN, password); LdapSearchResults lsc = conn.Search(searchBase, LdapConnection.SCOPE_SUB, searchFilter, null, false); var attributeListObject = new List<object>(); while (lsc.hasMore()) { LdapEntry nextEntry = null; try { nextEntry = lsc.next(); } catch (LdapException e) { Console.WriteLine("Error: " + e.LdapErrorMessage); continue; } var entry = new PersonEntry(); LdapAttributeSet attributeSet = nextEntry.getAttributeSet(); IEnumerator ienum = attributeSet.GetEnumerator(); while (ienum.MoveNext()) { LdapAttribute attribute = (LdapAttribute)ienum.Current; string attributeName = attribute.Name; string attributeVal = attribute.StringValue; if (!Base64.isLDIFSafe(attributeVal)) { byte[] tbyte = SupportClass.ToByteArray(attributeVal); attributeVal = Base64.encode(SupportClass.ToSByteArray(tbyte)); } switch (attributeName) { case "sAMAccountName": entry.UserName = attributeVal; break; case "displayName": entry.Name = attributeVal; break; case "telephoneNumber": entry.TelephoneNumber = attributeVal; break; case "thumbnailPhoto": var value = attribute.ByteValue; entry.ThumbnailPhoto = (byte[])(Array)value; break; default: break; } } attributeListObject.Add(entry); } conn.Disconnect(); return Ok(attributeListObject);
When i build it and it will take more than 20 seconds. See screenshot as below:
Is it possible to speed up loops for large data? if yes then how?
I am waiting for your response.
Thanks in advance!