ldap/src/main/java/org/springframework/security/ldap/authentication/SpringSecurityAuthenticationSource.java
public String getPrincipal() {
		Authentication authentication = SecurityContextHolder.getContext()
				.getAuthentication();

		if (authentication == null) {
			log.warn("No Authentication object set in SecurityContext - returning empty String as Principal");
			return "";
		}

		Object principal = authentication.getPrincipal();

		if (principal instanceof LdapUserDetails) {
			LdapUserDetails details = (LdapUserDetails) principal;
			return details.getDn();
		}
		else if (authentication instanceof AnonymousAuthenticationToken) {
			if (log.isDebugEnabled()) {
				log.debug("Anonymous Authentication, returning empty String as Principal");
			}
			return "";
		}
		else {
			throw new IllegalArgumentException(
					"The principal property of the authentication object"
							+ "needs to be an LdapUserDetails.");
		}
	}
public String getPrincipal() {
		Authentication authentication = SecurityContextHolder.getContext()
				.getAuthentication();

		if (authentication == null) {
			log.warn("No Authentication object set in SecurityContext - returning empty String as Principal");
			return "";
		}

		Object principal = authentication.getPrincipal();

		if (principal instanceof LdapUserDetails) {
			LdapUserDetails details = (LdapUserDetails) principal;
			return details.getDn();
		}
		else if (authentication instanceof AnonymousAuthenticationToken) {
			if (log.isDebugEnabled()) {
				log.debug("Anonymous Authentication, returning empty String as Principal");
			}
			return "";
		}
		else {
			throw new IllegalArgumentException(
					"The principal property of the authentication object"
							+ "needs to be an LdapUserDetails.");
		}
	}
public String getPrincipal ( ) { Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication == null ) { log . warn ( "No Authentication object set in SecurityContext - returning empty String as Principal" ) ; return "" ; } Object principal = authentication . getPrincipal ( ) ; if ( principal instanceof LdapUserDetails ) { LdapUserDetails details = ( LdapUserDetails ) principal ; return details . getDn ( ) ; } else if ( authentication instanceof AnonymousAuthenticationToken ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Anonymous Authentication, returning empty String as Principal" ) ; } return "" ; } else { throw new IllegalArgumentException ( "The principal property of the authentication object" + "needs to be an LdapUserDetails." ) ; } }
Get the principals of the logged in user, in this case the distinguished name.

@return the distinguished name of the logged in user.
Get the principals of the logged in user in this case the distinguished name .