/** * Search the LDAP user DN stored in an existing user profile with provided LDAP user uid stored. * <p> * If more than one profile is found the first one in returned and an error is logged. * * @param uid the LDAP unique id. * @return the found LDAP DN, null if it can't find one or if it's empty. */ public String searchDn(String uid) { XWikiDocument document = searchDocumentByUid(uid); return document == null ? null : getDn(document); } }
/** * Search the LDAP user DN stored in an existing user profile with provided LDAP user uid stored. * <p> * If more than one profile is found the first one in returned and an error is logged. * * @param uid the LDAP unique id. * @return the found LDAP DN, null if it can't find one or if it's empty. */ public String searchDn(String uid) { XWikiDocument document = searchDocumentByUid(uid); return document == null ? null : getDn(document); } }
/** * @param validXWikiUserName the valid XWiki name of the user to get the profile for. Used for fast lookup relying * on the document cache before doing a database search. * @param ldapUid the UID to get the profile for * @param context the XWiki context * @return the XWiki document of the user with the passed UID * @throws XWikiException when a problem occurs while retrieving the user profile */ public XWikiDocument getUserProfileByUid(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException { LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context); // Try default profile name (generally in the cache) XWikiDocument userProfile = context.getWiki().getDocument( new DocumentReference(context.getDatabase(), XWIKI_USER_SPACE, validXWikiUserName), context); if (!ldapUid.equalsIgnoreCase(ldapXClass.getUid(userProfile))) { // Search for existing profile with provided uid userProfile = ldapXClass.searchDocumentByUid(ldapUid); // Resolve default profile patch of an uid if (userProfile == null) { userProfile = getAvailableUserProfile(validXWikiUserName, ldapUid, context); } } return userProfile; }
/** * @param validXWikiUserName the valid XWiki name of the user to get the profile for. Used for fast lookup relying * on the document cache before doing a database search. * @param ldapUid the UID to get the profile for * @param context the XWiki context * @return the XWiki document of the user with the passed UID * @throws XWikiException when a problem occurs while retrieving the user profile */ public XWikiDocument getUserProfileByUid(String validXWikiUserName, String ldapUid, XWikiContext context) throws XWikiException { LDAPProfileXClass ldapXClass = new LDAPProfileXClass(context); // Try default profile name (generally in the cache) XWikiDocument userProfile = context.getWiki() .getDocument(new DocumentReference(context.getWikiId(), XWIKI_USER_SPACE, validXWikiUserName), context); if (!ldapUid.equalsIgnoreCase(ldapXClass.getUid(userProfile))) { // Search for existing profile with provided uid userProfile = ldapXClass.searchDocumentByUid(ldapUid); // Resolve default profile patch of an uid if (userProfile == null) { userProfile = getAvailableUserProfile(validXWikiUserName, ldapUid, context); } } return userProfile; }