public static LDAPUser getUserInfo(String crsid){
		LDAPUser result = new LDAPUser();
		
		Hashtable env = new Hashtable();
		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
		env.put(Context.PROVIDER_URL, "ldap://ldap.lookup.cam.ac.uk:389");

		Attributes a = null;
        try{
	        DirContext ctx = new InitialDirContext(env);
	        SearchControls controls = new SearchControls();
	        controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
	        SearchResult searchResult = ctx.search("ou=people,o=University of Cambridge,dc=cam,dc=ac,dc=uk", "(uid="+crsid+")", controls).next();
	        a = searchResult.getAttributes();
		}catch(Exception e){
        	log.error(e.getMessage());
        	return null;
        }
       
        try {
        	log.debug("Trying to obtain data for user " + crsid);
	        result.setId(crsid);
	        log.debug("Trying to obtain displayName for user " + crsid);
	        result.setDisplayName(a.get("displayName").get().toString());
	        log.debug("Trying to obtain email address for user " + crsid);
	        result.setEmail(a.get("mail").get().toString());
	        log.debug("Trying to obtain Institutions for user " + crsid);
	        result.setInstitutions(toList(a.get("ou")));
	        log.debug("Trying to obtain roles for user " + crsid);
	        result.setRoles(toList(a.get("title")));
	        log.debug("Trying to obtain misAffiliation for user " + crsid);
	        try{
	        	if(a.get("misAffiliation").get().toString().equals("staff")) {
	        		result.setStudent(false);
	        	}
	        	log.debug("Successfully got misAffiliation");
	        } catch(NullPointerException e){
	        	log.warn("Couldn't get misAffiliation! Probably returned null. User set to role student by default.");
	        }
	        
	        log.debug("Trying to get the image for user" + crsid);
	        try{
	        	byte[] x = (byte[])a.get("jpegPhoto").get();
	        	result.setImage(new String(Base64.encodeBase64(x)));
	        }catch(NullPointerException e){
	        	result.setImage(defaultImg());
	        }
	       
        } catch (NamingException e) {
			log.error(e.getMessage());
			return result;
		}
        log.debug("Returning user info for " + crsid);
        return result;
	}