views:

71

answers:

2

hi all,

I have a db with users that have all this record .

I would like to do a query on a data like

CN=aaa, OU=Domain,OU=User, OU=bbbbbb,OU=Department, OU=cccc, OU=AUTO, DC=dddddd, DC=com

and I need to group all users by the same ou=department.

How can I do the select with the substring to search a department??

My idea for the solution is to create another table that is like this:

---------------------------------------------------
ldapstring                           | society | site
---------------------------------------------------
"CN=aaa, OU=Domain,OU=User, OU=bbbbbb,OU=Department, OU=cccc, OU=AUTO, DC=dddddd, DC=com" | societyName1 | societySite1

and my idea is to compare the string with these on the new table with the tag like but how can I take the society and site when the like string occurs?????

Please help me

+1  A: 

Maybe you should look into MySQL regular expressions. I, myself, have never used it, but just wanted to suggest it :-)

http://dev.mysql.com/doc/refman/5.1/en/regexp.html

Kordonme
+3  A: 

You could always do ColumnName LIKE '%OU=Department%'.

Regardless, I think this needs to be normalized into a better table, if possible. Multivalue columns should be avoided as much as possible.

IF you aren't dealing with a database, the next best thing would be a regular expression.

Daniel A. White
Normalisation is the best way to do it.
DrDol
Normalize the minimum... maybe just break out the 'OU' column.
Tim Drisdelle