Mike

When running the script below, it changes the mailnickname(alias) but
all to the same value which seems to be the last user in the ou's
proxyaddresses which in this case is a.testuser3

So all 3 users in this OU now have an mailnickname(alias) of a.testuser3
instead of it picking the correct mail suffix from each of their
proxyaddresses.

Any ideas why this is happening from the code below ?

<!--- query LDAP --->

<cfldap action="query"
name="adresult"
attributes = "cn,dn, mailNickname, proxyAddresses"
START="ou=Test,DC=domain,dc=gov,dc=uk"
filter="(&(objectClass=User)(mail=*))"
server="server"
port="389"
username="username"
password="password"
>

<cfloop query="adresult">
<cfscript>
  s = "#adresult.mailNickname#";
  re = "SMTP:([EMAIL PROTECTED]).*";
  s = reReplaceNoCase(s, re, "\1", "all");
  writeoutput("#s#");
</cfscript>
</cfloop>

<cfloop query="adresult">
<cfldap
action="modify"
modifyType="replace"
attributes="mailNickname=#s#"
dn="#adresult.dn#"
server="server"
port="389"
username="username"
password="password">
</cfloop>

Changes Completed

-----Original Message-----
From: Dawson, Michael [mailto:[EMAIL PROTECTED] 
Sent: 06 April 2006 12:47
To: CF-Talk
Subject: RE: CFLDAP Question ?

You don't need a query around the first CFLDAP tag.  You only need to
loop around the second CFLDAP tag using the query results from the first
CFLDAP tag.

I think your first CFLDAP tag is fine, as long as it returns the correct
results for you.  Your second CFLDAP tag was just updating the "same" AD
object since you were only setting the DN, one time, "outside" of the
loop when you should have been using it "within" the loop.

This is the basic layout:

<cfldap name="adresult"...>

<cfloop query="adresult">
  <cfldap [modify stuff here]...>
</cfloop>

That structure should do it for you.  Just remember that CFLDAP will let
you return many records, but CFLDAP will "only" let you modify a
"single" record.  Hence, the need for a loop.

M!ke



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237079
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to