Powered By Blogger

Thursday, October 20, 2011

ldap sync in Alfresco





org.alfresco.repo.security.sync.UserRegistrySynchronizerJob







${synchronization.synchronizeChangesOnly}






${synchronization.import.cron}








From here it calls




ChainingUserRegistrySynchronizer.java has a method by name


syncWithPlugin

private void syncWithPlugin(final String zone, UserRegistry userRegistry, boolean forceUpdate,
boolean allowDeletions, boolean splitTxns, final Set visitedZoneIds, final Set allZoneIds)



It has

final BatchProcessor personProcessor = new BatchProcessor(zone
+ " User Creation and Association", this.transactionService.getRetryingTransactionHelper(),
userRegistry.getPersons(lastModified), this.workerThreads, 10, this.applicationEventPublisher,

userRegistry.getPersons(lastModified)


It calls LDAPUSerRegistry

/*
* (non-Javadoc)
* @see org.alfresco.repo.security.sync.UserRegistry#getPersons(java.util.Date)
*/
public Collection getPersons(Date modifiedSince)
{
return new PersonCollection(modifiedSince);
}


which in turn calls PersonCollection. The PersonCollection has the constructor to initialize the query


PersonIterator has the next to get the users from the system

private NodeDescription fetchNext() throws NamingException
{
boolean readyForNextPage;
do
{
readyForNextPage = this.searchResults == null;
while (!readyForNextPage && this.searchResults.hasMore())
{
SearchResult result = this.searchResults.next();
Attributes attributes = result.getAttributes();
Attribute uidAttribute = attributes.get(LDAPUserRegistry.this.userIdAttributeName);
if (uidAttribute == null)
{
if (LDAPUserRegistry.this.errorOnMissingUID)
{
throw new AlfrescoRuntimeException(
"User returned by user search does not have mandatory user id attribute "
+ attributes);
}
else
{
LDAPUserRegistry.logger
.warn("User returned by user search does not have mandatory user id attribute "
+ attributes);
continue;
}
}
String uid = (String) uidAttribute.get(0);

if (this.uids.contains(uid))
{
LDAPUserRegistry.logger
.warn("Duplicate uid found - there will be more than one person object for this user - "
+ uid);
}

this.uids.add(uid);

if (LDAPUserRegistry.logger.isDebugEnabled())
{
LDAPUserRegistry.logger.debug("Adding user for " + uid);
}

// Apply the mapped properties to the node description
return mapToNode(LDAPUserRegistry.this.personAttributeMapping,
LDAPUserRegistry.this.personAttributeDefaults, result);
}

// Examine the paged results control response for an indication that another page is available
if (!readyForNextPage)
{
readyForNextPage = LDAPUserRegistry.this.ldapInitialContextFactory.hasNextPage(this.ctx,
LDAPUserRegistry.this.queryBatchSize);
}

// Fetch the next page if there is one
if (readyForNextPage)
{
this.searchResults = this.ctx.search(LDAPUserRegistry.this.userSearchBase,
PersonCollection.this.query, this.userSearchCtls);
}
}
while (readyForNextPage);
this.searchResults.close();
this.searchResults = null;
this.ctx.close();
this.ctx = null;
return null;
}


No comments:

Post a Comment