Has anyone attempted to update groups using CFLDAP with any success?
In the following code, I've been able to update an attribute, say,
"homePhone", by putting it in place of #ATTRIBUTENAME# in the following code.
Then, I place the new home phone number in place of #ATTRIBUTEVALUE# and it
updates it perfectly. When I use the AD field, "member" as the
#ATTRIBUTENAME#, and update with a list of objects in their distinguishedname
format in #ATTRIBUTEVALUE# it doesn't update the "member" field in Active
Directory. Clear as mud?
<cfldap action="MODIFY" DN="#OBJECTDN#"
attributes="#ATTRIBUTENAME#=#ATTRIBUTEVALUE#" modifytype="REPLACE"
server="#DOMAINSERVER#" port="389" timeout="20" username="#USERNAME#"
password="#PASSWORD#">
The code used above is correct, however, it?s the format of the value of the
member attribute that needs to be changed. The reason it needs to be changed
is because the ?member? attribute contains a list of distinguished names (DNs)
separated by commas. Each part of a DN is separated by commas, so CFLDAP can?t
figure out where one DN starts and the next one begins.
Example:
member=CN=John Doe, OU=Corporate, OU=Users, DC=My Company, DC=int, CN=Jane
Doe, OU=Corporate, OU=Users, DC=My Company, DC=int, CN=Mike Anders,
OU=Corporate, OU=Users, DC=My Company, DC=int
So, what needs to happen is that we replace the commas at the end of each DN
with a different separator.
Example:
<cfset NEWMEMBER = REPLACE(MEMBER, ", CN", "|CN", "ALL")>
Which produces:
member=CN=John Doe, OU=Corporate, OU=Users, DC=My Company, DC=int|CN=Jane Doe,
OU=Corporate, OU=Users, DC=My Company, DC=int|CN=Mike Anders, OU=Corporate,
OU=Users, DC=My Company, DC=int
Then, we just need to tell CFLDAP that the value of "member" is separated with
?|? in the tag:
<cfldap action="MODIFY" DN="CN=IT Dept, OU=Groups, DC=My Company, DC=int"
attributes="member=#NEWMEMBER#" separator="|" modifytype="REPLACE" server="#
DOMAINSERVER#" port="389" timeout="20" username="# DOMAINADMINISTRATOR#"
password="# DOMAINPASSWORD#">
Active Directory will automatically update the ?memberof? attribute for each
of the users you add to the group. In fact, you can use the code above to
update just about any field to keep your Intranet synchronized with the
network. Just change member=#NEWMEMBER# to say, homePhone=555-555-5555 or any
of the other attributes available.