LDAP Lightweight Directory Access Protocol (Based on X 500 Standard)
LDAP --> Protocol to retrieve data stored in information directory, which is heavily optimized for read performance.
LDAP --> Allows you to securely delegate read and modification authority based on your specific needs using ACIs (collectively, an ACL, or Access Control List).
LDAP --> Tree Structure
Top level node called base DN (Distinguished Name)
Base DN in one of the 3 formats (for foobar company in US)
o="company name",c=Country
ex: o="foobar,Inc", c=US
(not preferred now a days,as no place to put website name)
o="website of the company"
ex: o=foobar.com (most common as straight forward)
dc=compnay, dc = com
ex: dc=foobar,dc=com
(used nowadays, Microsoft Acive Directory uses this format)
Here o=>organisation, c=>country,dc=>domain components
Under root base DN, Create nodes that logically seperate your data.
For Historic reasons (X500),These logical components are set up as OU,CN
OU=>Origanizational Unit
CN=>Common Name
All entires in LDAP have a unique DN and this DN is composed of 2 parts, RDN(Relative) and lcoation within the ldap direcotry where the record resides.
RDN is the portion of your DN that is not related to the directory tree structure.
Most entries stored in ldap will have a name, they are stored as CN
Most objects stored in LDAP will use CN value as RDN
So, If I want to store recipie for Oatmeal raisin
ex:
dc=foobar, dc=com
- ou=recipie
-- cn=oatmeal raisin
So, the full DN for the LDAP record is (Remeber it read it backwards) cn=oatmeal raisin,ou=recipie,dc=foobar,dc=com
Typically to store employee logins either CN is used store their name or UID is used to store the login
ex: dc=abclondon,dc=com
-ou=london
--cn="ramesh manni" or uid="rmanni" ----> name-based or login-based
LDAP stores all information for a given record as key-value pairs
ex:
dn: cn=Oatmeal Deluxe, ou=recipes, dc=foobar, dc=com
cn: Instant Oatmeal Deluxe
recipeCuisine: breakfast
recipeIngredient: 1 packet instant oatmeal
recipeIngredient: 1 cup water
recipeIngredient: 1 pinch salt
recipeIngredient: 1 tsp brown sugar
recipeIngredient: 1/4 apple, any type
Searches against these attribute/value pairs are case insensitive excpet for passwords
Wednesday, August 6, 2008
Monday, August 4, 2008
Oracle: Regular Expression: Examples
How to split strings like "ABC Company (XXX)" into "ABC Company", "XXX"
Select col1, regexp_substr(col1,'[^(]*') Comp_Name,
ltrim(regexp_substr(col1,'\([^)]*'),'(') comp_code
from ( Select 'ABC Company (XXX)' col1 from dual ).
Script does 3 things
1) For name, It takes everything till it hits '('
2) For Code, it takes everything from '(' [you need to escape open paranthesis symbol], till it finds the closing parenthesis ')'.
3) Ltrim is to remove the Open parenthesis in the code.
Select col1, regexp_substr(col1,'[^(]*') Comp_Name,
ltrim(regexp_substr(col1,'\([^)]*'),'(') comp_code
from ( Select 'ABC Company (XXX)' col1 from dual ).
Script does 3 things
1) For name, It takes everything till it hits '('
2) For Code, it takes everything from '(' [you need to escape open paranthesis symbol], till it finds the closing parenthesis ')'.
3) Ltrim is to remove the Open parenthesis in the code.
Oracle: Regular Expression: Examples
How to split strings like "ABC Company (XXX)" into "ABC Company", "XXX"
Select col1, regexp_substr(col1,'[^(]*') Comp_Name,
ltrim(regexp_substr(col1,'\([^)]*'),'(') comp_code
from ( Select 'ABC Company (XXX)' col1 from dual ).
Script does 3 things
1) For name, It takes everything till it hits '('
2) For Code, it takes everything from '(' [you need to escape open paranthesis symbol], till it finds the closing parenthesis ')'.
3) Ltrim is to remove the Open parenthesis in the code.
Select col1, regexp_substr(col1,'[^(]*') Comp_Name,
ltrim(regexp_substr(col1,'\([^)]*'),'(') comp_code
from ( Select 'ABC Company (XXX)' col1 from dual ).
Script does 3 things
1) For name, It takes everything till it hits '('
2) For Code, it takes everything from '(' [you need to escape open paranthesis symbol], till it finds the closing parenthesis ')'.
3) Ltrim is to remove the Open parenthesis in the code.
Regular Expression: How to split comma seperated values using sql
Lets create a table first and insert few comma seperated rows.
1) create table tab1 (owner number, cars varchar2(200));
2) insert into tab1 (
select 1, 'Ford,Toyota,Nissan' from dual union all
select 2, 'Lexus,Mercedes,BMW,Infiniti' from dual union all
select 3, 'Ferrari' from dual union all
select 4, 'Porsche,Lotus,Lamborghini,Maserati,Aston Martin' from dual union all
select 5, 'Maybach,Bentley' from dual);
3) select owner, cars str from tab1;
Now here is the sql to split.
select owner, car
from ( select owner, regexp_substr(str, '[^,]+', 1, level) car,
level lv, lag(level, 1, 0) over (partition by owner order by level) lg
from ( select owner, cars str from tab1 )
connect by regexp_substr(str, '[^,]+', 1, level) is not null
)
where lv != lg;
Replace"," in [^,] with your delimiter
1) create table tab1 (owner number, cars varchar2(200));
2) insert into tab1 (
select 1, 'Ford,Toyota,Nissan' from dual union all
select 2, 'Lexus,Mercedes,BMW,Infiniti' from dual union all
select 3, 'Ferrari' from dual union all
select 4, 'Porsche,Lotus,Lamborghini,Maserati,Aston Martin' from dual union all
select 5, 'Maybach,Bentley' from dual);
3) select owner, cars str from tab1;
Now here is the sql to split.
select owner, car
from ( select owner, regexp_substr(str, '[^,]+', 1, level) car,
level lv, lag(level, 1, 0) over (partition by owner order by level) lg
from ( select owner, cars str from tab1 )
connect by regexp_substr(str, '[^,]+', 1, level) is not null
)
where lv != lg;
Replace"," in [^,] with your delimiter
Subscribe to:
Posts (Atom)