/// <summary> /// Takes in an Email and returns a LDAP Object(Person Object) of that User /// </summary> /// <param name="emailAlias"></param> /// <returns>LDAPuser</returns> public static LDAPuser getLDAPEntryByEmailAlias(string emailAlias) { // Split the email address and get the contents before the @ string[] splitEmailAlias = emailAlias.Split('@'); string templeEduTUNA = splitEmailAlias[0]; // Create the WebService proxy, send the search request and receive the TempleLDAPEntry object LDAP_Search ldapProxy = new LDAP_Search(); TempleLDAPEntry[] results = new TempleLDAPEntry[1]; results = ldapProxy.Search(webServiceUsername, webServicePassword, "templeEduTUNA", templeEduTUNA); TempleLDAPEntry resultEntry = results[0]; // Check if request was successful if (resultEntry.error == null) // Success { // Create our TempleLDAPEntry object to be returned LDAPuser personLDAPEntry = new LDAPuser(); personLDAPEntry.templeEduID = resultEntry.templeEduTUID; personLDAPEntry.uID = resultEntry.uid; personLDAPEntry.cn = resultEntry.cn; personLDAPEntry.givenName = resultEntry.givenName; personLDAPEntry.sn = resultEntry.sn; personLDAPEntry.eduPersonAffiliation = resultEntry.eduPersonAffiliation; personLDAPEntry.eduPersonPrimaryAffiliation = resultEntry.eduPersonPrimaryAffiliation; personLDAPEntry.mail = resultEntry.mail; personLDAPEntry.title = resultEntry.title; return(personLDAPEntry); } else // Something went wrong.. { return(null); } }
/// <summary> /// takes in a faculty TUID and returns a string of the title(ie. Employee, Faculty) they hold /// </summary> /// <param name="TUID"></param> /// <returns>String</returns> public static String getFacultyTitleByTUID(string TUID) { // Create the WebService proxy, send the search request and receive the TempleLDAPEntry object LDAP_Search ldapProxy = new LDAP_Search(); TempleLDAPEntry[] results = new TempleLDAPEntry[1]; results = ldapProxy.Search(webServiceUsername, webServicePassword, "templeEduTUID", TUID); TempleLDAPEntry resultEntry = results[0]; // Check if request was successful if (resultEntry.error == null) // Success { string[] affiliations = resultEntry.eduPersonAffiliation.Split(','); foreach (string s in affiliations) { if (s.Equals("faculty")) { return(resultEntry.title); } } return(null); } else // Something went wrong.. { return(null); } }
/// <summary> /// Takes in an accessnet and returns an LDAPuser (Person Object) based on that AccessnetID /// </summary> /// <param name="accessnetID"></param> /// <returns>LDAPuser</returns> public static LDAPuser getLDAPEntryByAccessnet(string accessnetID) { // Create the WebService proxy, send the search request and receive the TempleLDAPEntry object LDAP_Search ldapProxy = new LDAP_Search(); TempleLDAPEntry[] results = new TempleLDAPEntry[1]; results = ldapProxy.Search(webServiceUsername, webServicePassword, "uid", accessnetID); TempleLDAPEntry resultEntry = results[0]; // Check if request was successful if (resultEntry.error == null) // Success { // Create our TempleLDAPEntry object to be returned LDAPuser personLDAPEntry = new LDAPuser(); personLDAPEntry.templeEduID = resultEntry.templeEduTUID; personLDAPEntry.uID = resultEntry.uid; personLDAPEntry.cn = resultEntry.cn; personLDAPEntry.givenName = resultEntry.givenName; personLDAPEntry.sn = resultEntry.sn; personLDAPEntry.eduPersonAffiliation = resultEntry.eduPersonAffiliation; personLDAPEntry.eduPersonPrimaryAffiliation = resultEntry.eduPersonPrimaryAffiliation; personLDAPEntry.mail = resultEntry.mail; personLDAPEntry.title = resultEntry.title; return(personLDAPEntry); } else // Something went wrong.. { return(null); } }