I am geting an index out of bounds error, I understand why I am getting it. What I am looking for is perhaps some features of c# I may not be aware of instead of using a bulky if/else statement.
If the Active Directory user does not have a job title this errors out because it will not load the property so rs.Propterties["title"] doesn't even exist to my knowledge.
Is there a cleaner way to do it than if (rs.Properties["title"].Count)
user.jobTitle = rs.Properties["title"][0].ToString();
I was looking into different operators like ?? and ?: but couldn't figure out how to get them to work properly.
rs.Properties is of type SearchResult from:
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.DirectoryServices.AccountManagement;