This is another post from my old blog. Again - the information here is old so it may not be useful for the recent versions of Asterisk. It is for Asterisk 1.4.
I had to use an LDAP server to retrieve SIP accounts for Asterisk. I had some difficulties to make it work, so I'll describe what I did here. Officially in Asterisk 1.4 there is no LDAP support, but there is a plugin in SVN, which works with the trunk version. You can get it from here. res_config_ldap.c should be added in res from Asterisk source code directory. Then compile this way:
Then edit res_ldap.conf. You can get a sample from here. In the section [sip] you should add this line, for clear text password (highly unrecommended!):
In extconfig.conf this lines should be added:
sippeers => ldap,"ou=accounts,dc=example,dc=com",sip sipusers => ldap,"ou=accounts,dc=example,dc=com",sip
And finally the LDAP server should include this schema. Restart Asterisk and everything should be fine.