WebSphere Portal Server - Re: Forcing Password Change

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > June 2004 > Re: Forcing Password Change





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Forcing Password Change
craigdawson

2004-06-21, 5:50 pm

You need to do an LDAP search. Something like this, pardon the formatting:

// Create the default search controls
SearchControls ctls = new SearchControls();
String[] attrsToReturn = {ATTRIB_DISTINGUISHED_NAME, ATTRIB_COMMON_NAME, ATTRIB_SURNAME, ATTRIB_NAME, ATTRIB_MEMBER_OF};
ctls.setReturningAttributes(attrsToReturn);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);

// Retrieve objects of type 'user' that have the attribute "sAMAccountName" == userid
String filter = "(&(objectclass=" + settings.getUserObjectClass() + ")(" + settings.getUserIdAttribute()
+ "=" + userId + "))";

searchBase = settings.getLdapSearchBase();
// Search for objects using the filter
NamingEnumeration answer = context.search(searchBase, filter, ctls);

while (answer.hasMore()) {
//user found
SearchResult searchResult = (SearchResult)answer.next();

attrs = searchResult.getAttributes();

userBean.setDistinguishedName(attrs.get(ATTRIB_DISTINGUISHED_NAME).get(0).toString());

if (attrs.get(ATTRIB_SURNAME) != null) {
userBean.setLastName(attrs.get(ATTRIB_SURNAME).get(0).toString());
}
if (attrs.get(ATTRIB_MEMBER_OF) != null) {
userBean.setGroups(getGroups(attrs));
}
if (attrs.get(ATTRIB_NAME) != null) {
userBean.setFirstName(getFirstName(attrs.get(ATTRIB_NAME).get(0).toString()));
}
userBean.setUserId(userId);

}
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com