I am trying to combine the search results from two separate directories. One being LDAP the other being a database.
var ldapResults = new List<LdapResult>();
var databaseResults = new List<DatabaseResult>();
class LdapResult
{
string sso { get; set; }
string name { get; set; }
string mail { get; set; }
}
class DatabaseResult
{
string sso { get; set; }
string name { get; set; }
string legacyAccountName { get; set; }
string phone { get; set; }
}
class SearchResult
{
string sso { get; set; }
string name { get; set; }
string mail { get; set; }
string legacyAccountName { get; set; }
string phone { get; set; }
}
A user can exist in both or either and I want the results from both of them with a preference to the LDAP results if there are any.
LdapResult { "Bob", "Bob Bobinson", "bob@bob.com" }
LdapResult { "Jerry", "Jerry Seinfield" "jerry@yesman.com" }
DatabaseResult { "Bob", "BOB BOBIN", "L1234", "(123) 456-7890" }
DatabaseResult { "Mary", "POPPINS, MARY", "L8394", "(555) 555-5555" }
I'd like the result in that scenario be:
List<SearchResult> = [
{ "Bob", "Bob Bobinson", "bob@bob.com", "L1234", "(123) 456-7890" },
{ "Jerry", "Jerry Seinfield", "jerry@yesman.com", null, null },
{ "Mary", "POPPINS, MARY", null, "L8394", "(555) 555-5555" }
]
I have looked into concatination then removing duplicates, unions, and joins, but all have a priority over the first source list I'm comparing it to, usually associated with a unique identifier that has to be in the source list.
Unions get close, but if say a sso exists in list one it will just skip list 2. Joins will skip list 2 if the sso doesn't exist in list 1, etc.
UPDATE 1/23 6:49 PM EST: sso is a unique identifier in this scenario. It is equivalent to a single sign on identifier in my organization.
The problem comes in when new users don't exist in legacy, old users don't exist in modern, and everyone else has both.
- sso is a unique identifier
- LDAP name will be preferred (that is actually the only property that is preferred--legacy systems produce names like "BOB BOBBIN" which is clearly not preferred but is usable if it's all I have).
- Both LdapResult and DatabaseResult contain additional properties not in each other.
I changed samAccountName in this example to sso as samAccountName was a poor choice for the example on my part.