Jay Rizzi
Jay Rizzi

Reputation: 4304

cfldap get 1st value from an attribute separated by comma

I want to be able to assign a session variable from a ldap query of an attribute, but the attribute has commas separating the data, all i want is the first value from the attribute

<cfldap action="query"
                name="auth"
                attributes="uid, cn, mail"
                referral="yes"
                start="#LDAP_root#"
                scope="SUBTREE"
                server="#LDAP_server#"
                port="#LDAP_port#"
                filter="#userfilter#"
                username="#LDAP_username#"
                password="#LDAP_password#"
                secure = "CFSSL_BASIC"
                separator = ","

            > 
<!--- auth cn can have multiple values separated by a comma, i just want the first --->
<cfset session.fullname = auth.cn>

I am guessing a loop or a list, but unsure

Upvotes: 0

Views: 199

Answers (2)

tparton42
tparton42

Reputation: 31

You could also use either the listGetAt() or getToken() functions, and specify which element you want, as well as the delimiter. Which may be handy if you want say the second or third element.

<cfset foo = listGetAt(list, position, delimiter) />

Upvotes: 1

Matt Busche
Matt Busche

Reputation: 14333

If you have a list you can do listFirst(variable,delimiter) if the list is comma delimited you can ignore the delimiter.

Upvotes: 2

Related Questions