Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
4 subscribers
Views
2960 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
userSearch Function and LDAP
claudiob
over 7 years ago
#LDAP #userSearchI'm importing the manager field from LDAP into a customField1. The value that comes from Active Directory is "CN=Jetson\\, George,OU=Users,OU=Metropolis,DC=SpacelySprockets,DC=local "i can isolate the first name and last name by usign the extract(), substitute() and split() functions. split( substitute( extract(user(ri!user,"customField1"),"CN=",",OU="),"\\",""),",") which results in a list of text string "Jetson; George"Since the value property of userSearch() takes a "list of Text String" I should be able to pass the output of the split function to the userSearch function and get gjetson, the user expected. I can confirm the user exists by trying this piece of code... usersearch({"lastName","firstName"},{1,1}, {"Jetson","George"}) and confirm the user gjetson is returned.however, when I try using the output of split as the value property, it always returns a null. I've tried multiple permutations. loa...
OriginalPostID-248022
Discussion posts and replies are publicly visible
0
claudiob
over 7 years ago
...d(local!name:split( substitute( extract(user(ri!user,"customField1"),"CN=",",OU="),"\\",""),","),usersearch({"lastName","firstName"},{1,1}, local!name))substituting local!name with the split code. attempting conversions of each individual element of the array and putting into a string. etc. Does anyone know the trick to programmatically use userSearch to get a user from the system?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 7 years ago
@claudiob As far as my observation is considered, there is an additional space being appended to firstName in the LDAP search string which might be the root cause of issue. Please find attached the picture and I believe it might give you leads. Also if you can debug by using the wherecontains() on the output of split() and the actual array of lastName, firstName (i.e., {"Jetson","George"}) you can see that firstName won't appear in search results.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 7 years ago
If the above is correct, then you may slightly change the way(refer the code below) you split provided if it's a standard pattern across all the values:
load(
local!name: split(
substitute(
extract(
"CN=Jetson\\, George,OU=Users,OU=Metropolis,DC=SpacelySprockets,DC=local ",
"CN=",
",OU="
),
"\\",
""
),
", "
/*Use the comma with space as a separator(rather than comma) in the split(), as there is a space after the comma, that is prior to firstName*/
),
usersearch(
{
"lastName",
"firstName"
},
{
1,
1
},
local!name
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
claudiob
over 7 years ago
thanks sikhivahan, interesting catch. I don't think I've experienced the same issue in other languages. Splitting on ", " did not work, but substituting the " " with "" actually did. Thanks for the redirection.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 7 years ago
@claudiob No worries, ", " worked for me with the string you have mentioned in the post. Good to hear that it's resolved.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
claudiob
over 7 years ago
This was the final resolution in case anyone is interested... split( clean(substitute( substitute( extract( user(ri!user,"customField1"), "CN=", ",OU=" ), "\\,", ""),"'","")), " ") ...the second substitute removes apostrophe's like O'dell. The clean() removes any extra white space. I'm sure there will be other special cases to remove but this works for now. Thanks for the help.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel