ç§ãã¡ã¯ãActive DirectoryãAsterisk IPãã¬ãã©ããŒãµãŒããŒãOpenFire JabberãµãŒããŒã®ä»²éã§ãã
ãã¹ãŠãåå¥ã«ã€ã³ã¹ããŒã«ããããšã«ã€ããŠã¯è§ŠããŸããããã¹ãŠãååã«èª¬æãããŠãããåã ã«çŽ æŽãããæ©èœããŸãã ãã®ãã¹ãŠãã©ã®ããã«çµã¿åãããããåºäŒã£ãããšããã£ãããšãæžããŸãã
åŠåïŒ
ãã¡ã€ã³ã³ã³ãããŒã©ãŒdc.steepler.local ïŒ 10.10.8.200 ïŒããããŸãã ãã¡ã€ã³ããããã-steepler.localã ãµãŒããŒã«ã¯ãŠãŒã¶ãŒããããéšéãªã©ã«beatãããŠããŸãã éèŠãªããš-ãé»è©±ãåã®åãŠãŒã¶ãŒã®çªå·ã¯ãã¢ã¹ã¿ãªã¹ã¯ãµãŒããŒã«ãããŸãã
ã€ã³ã¹ããŒã«æžã¿ã®Asterisk VoIPãµãŒããŒïŒ 10.10.8.98 ïŒããããŸãã ãã¹ãŠã®ãŠãŒã¶ãŒã¯ãããããããã€ã¹ãSIPãä»ããŠæ¥ç¶ãããŸããã¢ã¹ã¿ãªã¹ã¯ã®ç解ã§ã¯ãã¿ã€ãã¯SIP / XXXïŒXXXã¯å ç·çªå·ïŒã§ãã ãã®èšäºãæžããŠããæç¹ã§ã¯ããµãŒããŒã¯ããªãåã«ã€ã³ã¹ããŒã«ãããŠããããã§ã«æ·±å»ãªèšå®ãè¡ãããŠããŸãã ããããäœæ¥ãè«ççãªçµããã«è³ããªãã£ãçç±ã§ããè«ççãªçµããã¯ãSIP端æ«ââããã€ã¹æ§æãšãã€ã€ã«ãã©ã³ã®èªåçæã§ãã æ®å¿µãªãããæ¢åã®æ§æãçå£ã«æžãçŽããªããã°ãªããªãã®ã§ã¯ãªãããšå¿é ããŸããããããã«ãããçµç¹ã«ååšããå€ãã®ã€ã³ã¿ã©ã¯ãã£ããªã¡ãã¥ãŒããã®ä»ã®ã«ã¹ã¿ãã€ãºãè¡ããã€ã€ã«ãã©ã³ã®èªåçæã¯ãã¿ã¹ã¯ã«çŽé¢ããŠããèªè ã«ãšã£ãŠèå³æ·±ããã®ã§ã¯ãããŸããããŸãããµãŒããŒãæ¥ç¶ããŸãã 次ã«é²ãã¹ãå Žæã¯æ確ã§ãã æžãããã¹ã¯ãªããã¯è€éã§ã¯ãªããä»åŸã®äœæ¥ã®ããã«ååãªäœè£ããããŸãã
ãã®ãããFreePBXããã³ããšã³ããã€ã³ã¹ããŒã«ãããã¢ã¹ã¿ãªã¹ã¯ããããã¿ã¹ã¯ãéåžžã«è€éã«ãªããŸããã FreePBXã«ã¯ç¿æ £ããããWebã€ã³ã¿ãŒãã§ãŒã¹ã«å€æŽãå ããåŸããã¹ãŠã®æ§æãã¡ã€ã«ãäžæžãããå¿ èŠãããããã§ãã ã€ãŸããã³ãã³ãã©ã€ã³ããèšå®ãå€æŽã§ããŸãããåŸã§Webãã§ã€ã¹ã§äœããå€æŽãããšãèšå®ã¯é©åãªããã³ããšã³ããšããŠFreePBXã«ãã£ãŠæ¶å»ãããŸãã ãã¡ãããã·ã§ã«ã®äœæè ã¯å€©æã«é Œããã埮調æŽã®æ©äŒãæ®ããŸããã ãã®å¯èœæ§ã¯ãæ¥å°ŸèŸã-customãïŒæçµçã«ã¯ååã§ããããšãå€æïŒã®è¿œå ã³ã³ããã¹ããããŒãããããå¿ èŠãªå€æŽãå³å¯ã«èšé²ããããªãŒããŒã©ã€ããæ§æã䜿çšããŠå®çŸãããŸãã ãã ããFreePBX Webã€ã³ã¿ãŒãã§ãŒã¹ã«é¢ä¿ãªããã«ã¹ã¿ã èšå®ãŸãã¯ãªãŒããŒã©ã€ãèšå®ã§èšè¿°ãããå 容ããããªãã®æèŠã§æ©èœããããšãç解ããå¿ èŠããããŸãã ãã§ãã«ãŒããŸãã¯è¡ãã ã€ãŸããããã³ããšã³ãã§äœãã²ãã£ãŠããã©ããªèšå®ã§ã-ã«ã¹ã¿ã èšå®ã«è§ŠããŠããã°-ããã³ããšã³ãã§ã¯ãªãããã¡ã€ã«ããã®èšå®ãæ©èœããŸãã ãã®ãããFreePBXã«ãã£ãŠçæããããã€ã€ã«ãã©ã³ã®ãã¬ãŒã¹ã«å€ãã®æéãè²»ããããŸããããã®ãããªæé ã§ãšã³ããªãã€ã³ããèŠã€ããããšæããŸããã
å·çæç¹ã§ã¯ãJabberãµãŒããŒã¯ãããŸããã§ããã äžå¯è§£ãªçç±ã§ãéžæã¯OpenFireã«èœã¡ãŸããã å®éãçç±ã¯ç°¡åã§ã-OpenFireã§ã¯ããšã³ãããŒãšã³ãïŒKerberos / GSSAPI / SASLïŒã®ãŠãŒã¶ãŒèªèšŒãæŽçã§ããŸãã ã€ãŸãããŠãŒã¶ãŒã¯ãã°ã€ã³ãŸãã¯ãã¹ã¯ãŒããå ¥åããå¿ èŠã¯ãããŸããã 圌ããŠã£ã³ããŠã«å ¥ããšãã«ãã¡ã€ã³èªèšŒã«åæ Œããå Žå-圌ã¯ç§ãã¡ã®ã¯ã©ã€ã¢ã³ãã§ãã ã¯ã©ã€ã¢ã³ããèµ·åãããšããŠãŒã¶ãŒã眮æããjabberãµãŒããŒã«ãªã¯ãšã¹ããéä¿¡ããŸãããã®ã¯ã©ã€ã¢ã³ãã¯ãKerberosã䜿çšããŠãã¯ã©ã€ã¢ã³ãã®ãªã¯ãšã¹ãã®ä¿¡é Œæ§ã確èªãŸãã¯æåŠããŸãã ãã¡ã€ã³ã®ãã¹ã¯ãŒããå®æçã«å€æŽããããªã·ãŒãååšããå Žåã§ãã詳现ã«ã€ããŠã¯èª¬æããŸããããæ¿èªã¯ã¯ã©ã€ã¢ã³ãã«å¯ŸããŠééçã§ããããšãéèŠã§ãã ãã¹ã¯ãŒããå€æŽãå¿ããããã«äœããæ©èœããªããªã£ããšããèŠæ ãåœå±ã«èšŽãããæããªãŠãŒã¶ãŒãã«ã€ããŠã®ã¹ããŒãªãŒãçæãã¹ãã§ã¯ãããŸããã ããªãã¯åœŒããæããªå Žæããªãããšã確èªããå¿ èŠããããŸãã
OpenFireã§ã¯ãæšæºã®Asterisk-IMãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããŠãAsteriskãšéä¿¡ã§ããŸãã ããã«ããããŠãŒã¶ãŒã¹ããŒã¿ã¹ã®åçãªç£èŠãIPé»è©±ã®åŒã³åºããéç¥ã®éä¿¡ãå¯èœã«ãªããŸãã æ®å¿µãªãããããã«äœ¿çšã§ããèªååã«ã¯å€ãã®èŠæãæ®ãããŠããŸã.ADãä»ãããšã³ãããŒãšã³ãã®èªèšŒãšèš±å¯ãå¯èœã§ããããŠãŒã¶ãŒã®è·å Žã®é»è©±ã®æ å ±ãæåã«ADã§æäŸããããšããäºå®ã«ãããããããAD /ã¢ã¹ã¿ãªã¹ã¯ãŠãŒã¶ãŒãæåã§ãããã³ã°ããå¿ èŠããããŸãã
ã ããã JabberãµãŒããŒã¯OpenFireã§ããã jbrgseveren01.steepler.localãåŒã³åºãã10.10.8.226ã§åäœããå¿ èŠããããŸãã
ããã«ãCentOS5ãAsterisk 1.8.2ãããã³Win2008ãã¡ã€ã³ã³ã³ãããŒã©ãŒã®åœ¢åŒã®Linuxããããšæ³å®ããŠããŸãã ããã¯çµ¶å¯Ÿã«åºæ¬çãªããšã§ã¯ãããŸããããä»ã®å Žåã§ãæ©èœããŸãã éèŠãªã®ã¯ã¢ã¹ã¿ãªã¹ã¯ããŒãžã§ã³ã®ã¿ã§ããjabberãµããŒãã¯1.6ãã©ã³ãããã®ã¿ç»å ŽããPBXã¯ãã®ãµããŒãã䜿çšããŠã³ã³ãã€ã«ããå¿ èŠããããŸãã
ã¿ã¹ã¯ïŒ
JabberãµãŒããŒãã€ã³ã¹ããŒã«ããIMãã¡ã€ã³ã°ã«ãŒãããå¿ èŠãªãŠãŒã¶ãŒãååŸããããã«èšå®ããå¿ èŠããããŸãã ãã¡ã€ã³ãŠãŒã¶ãŒããžã£ããŒãŠãŒã¶ãŒãã¢ã¹ã¿ãªã¹ã¯ãµãã¹ã¯ã©ã€ããŒã«é¢ããæ å ±ã®ãããã³ã°ãäœããã®æ¹æ³ã§èªååããå¿ èŠããããŸãã
ãã¹ãŠã¯ç®±ããåºããŠã©ã®ããã«æ©èœããŸããïŒ ïŒãŸãã¯èœãšãç©ŽïŒ
OpenFireã¯ãldapãããã³ã«çµç±ã§ãã¡ã€ã³ã³ã³ãããŒã©ãŒã«ã¢ã¯ã»ã¹ããjabberã®äœ¿çšãèš±å¯ãããŠãããŠãŒã¶ãŒã«é¢ããæ å ±ãåä¿¡ããŸãã
次ã«ãAsterisk-IMãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒOpenFire Webãã§ã€ã¹ã§2åã¯ãªãã¯ïŒã ãã©ã°ã€ã³ã§ã¯ãAsteriskãµãŒããŒãç»é²ããå¿ èŠããããŸãã ãããŠãããªãã®æã§ãèšç»ã®ãã¹ãŠã®ãŠãŒã¶ãŒãåç»é²ããŸã-ãã°ã€ã³-é»è©±çªå·-ã¢ã¹ã¿ãªã¹ã¯ã®ç解ã§ãã®å å ¥è ããã€ã¹ã ãã®åŸããã©ã°ã€ã³ã®æ©èœã¯åäœããŸããSparkãšåŒã°ãããã€ãã£ãOpenFireã¯ã©ã€ã¢ã³ãã®å©ããåããŠããŠãŒã¶ãŒã¯é£çµ¡å ãªã¹ããã¯ãªãã¯ããã ãã§ãæ¢åã®é»è©±ã䜿çšããŠãäºãã«é»è©±ããããããšãã§ããŸãã ã€ãŸããé£çµ¡å ãèŠã€ããŠå³ããŠã¹ã§ãåŒã³åºãããã¯ãªãã¯ããé»è©±ããã¹ã¯ã§é³Žãå§ããé»è©±ãåããããã«é£çµ¡å ã§é»è©±ã鳎ãå§ããŸãã ããã«ã誰ããé»è©±ã§è©±ããšãé£çµ¡å ãªã¹ãã®åœŒã®ã¹ããŒã¿ã¹ã¯å¯Ÿå¿ãããã®ã«å€ãããŸãã 䟿å©ã«ã ãã ãããŠãŒã¶ãŒã®åŠæ¹äœæ¥ã¯èªååããå¿ èŠããããŸãã
ããã«å ã«é²ã¿ãŸã-äžåšçä¿¡ã®éç¥ãjabberã«éä¿¡ããããšããèŠæããããŸãã é»è©±ã®ã©ã³ããç¹æ» ããã¡ãã¥ãŒã«å ¥ã£ãŠèª°ãé»è©±ããããã®ãã確èªããå¿ èŠãããå Žåãšãçºä¿¡è ã®æ£ç¢ºãªæéãšåº§æšãèšèŒãããã¡ãã»ãŒãžãåä¿¡ããå ŽåããããŸãã ç®±ããåºããŠããã«ã¯å®è£ ãããŠããŸããã ã€ãŸããAsteriskã¯ãã¡ãããã¯ã©ã€ã¢ã³ãã¢ãŒããŸãã¯ã³ã³ããŒãã³ãã¢ãŒãã§OpenFireãµãŒããŒã«ç°¡åã«åºå·ããŸãããã¡ãã»ãŒãžã®åŠçãšéä¿¡ã®ãããªãã¿ã¹ã¯ã¯ãã¹ãŠããªãã®è©ã«ããã£ãŠããŸãã ãã¡ãããéä¿¡äœæ¥èªäœã§ã¯ãªããã¢ã¹ã¿ãªã¹ã¯ã«é¢ãã説æäœæ¥ã§ã;-)ããã§æãæããªè§£æ±ºçã¯ãåçªå·ãåå¥ã«åŠçããããšã§ãã ãããã5ã€ãè¶ ããæ°ãããå Žåãããã¯ç§ãã¡ã«ã¯åããŸããã ããã«ããŠãŒã¶ãŒãé»è©±éã移åããæ°ããé»è©±ãè¿œå ããå€ãé»è©±ãåé€ããå¯èœæ§ããããŸãã ããã«ãFreePBXã«ã€ããŠãå¿ããªãã§ãã ããã æ¡çšã®ã«ãŒã«ãå³å¯ã«å®çŸ©ãããšããã°ãããWebã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããæ©äŒã倱ãããŸãã äžè¬çã«ã倱瀌ãæåŠããŸãã 転ãããŸããã ãã€ã€ã«ãã©ã³ã®ãšã³ããªãã€ã³ããèŠã€ããã¢ãã¬ã¹ã®çªå·ã§å¯Ÿå¿ãããã¡ã€ã³ãŠãŒã¶ãŒãæ€çŽ¢ããç¬èªã®æé ãäœæããå¿ èŠããããŸããããã€ã€ã«ãªããã®å Žåã¯ããžã£ããŒã«ã¡ãã»ãŒãžãéä¿¡ããŸãã ã
éãã
æåã«å¿ èŠãªã®ã¯ãŠãŒã¶ãŒã§ãã ãã¡ã€ã³ã«2人ã®ãŠãŒã¶ãŒãäœæããŸãã LDAPèªèšŒçšã«1ã€ãKerberosçšã«ãã1ã€ãå¿ èŠã«ãªããŸãã æåã«openfireã2çªç®ã«xmpp-openfireãåŒã³åºããŸããã 次ã«-jabberãŠãŒã¶ãŒïŒIMãšããååã®ã°ã«ãŒãïŒã®ã°ã«ãŒããããã«äœæããå¿ èŠãªãŠãŒã¶ãŒãè¿œå ããŸãã å éšé»è©±ãæã¡ããé»è©±çªå·ããã£ãŒã«ãã®IMã°ã«ãŒãã®ã¡ã³ããŒã§ãããã¹ãŠã®ãŠãŒã¶ãŒããå å ¥è ã®å ç·çªå·ãæ£ç¢ºã«æã£ãŠããããšã確èªããŸãã
2çªç®-å°æ¥ã®jabberãµãŒããŒãDNSã§èŠå®ããŸãã é ãŸãŒã³ãšéãŸãŒã³ã®äž¡æ¹ãå¿ èŠã§ãã jabberãµãŒããŒèªäœã§ããã¹ãåãæ§æããŸã- / etc / hostsã«æžã蟌ã¿ãŸã ïŒ
127.0.0.1 localhost.localdomain localhost 10.10.8.226 jbrgseveren01.steepler.local jbrgseveren01
nslookupã䜿çšããŠãã¹ãŠã®åŽãã確èªããŸãããã¹ãŠãæ£ãã解決ãããã¯ãã§ãã ã¯ãããã¹ãåã¯å°æåã§ãã ããã¯éèŠã§ãã
第äž-æ瀺ã«åŸã£ãŠOpenFireãã€ã³ã¹ããŒã«ããŸã-http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/ldap-guide.html
ããã«ã¯ãã¹ãŠã·ã³ãã«ã§ãèœãšãç©Žã¯ãããŸããã æ倧ã®è€éãã¯ãLDAPãªã¯ãšã¹ãå ã®é©åãªãã£ã«ã¿ãŒã®åœ¢æã§ãã æåã®ãŠãŒã¶ãŒãä»ããŠæ¥ç¶ãããŠããŸãã åºåã¯ãADãä»ãããšã³ãããŒãšã³ãèªèšŒãåããæ©èœããŠãããµãŒããŒã«ãªããŸãã ã¯ã©ã€ã¢ã³ããæ¥ç¶ããŠäœæ¥ã§ããŸãã ããããç§ãã¡ã®ä»äºã¯SSOïŒã·ã³ã°ã«ãµã€ã³ãªã³ã§ãã ãŠãŒã¶ãŒã¯ãã¯ã©ã€ã¢ã³ãã®ãŠãŒã¶ãŒåãšãã¹ã¯ãŒãã«ã€ããŠèããå¿ èŠããããŸããã
Kerberosã®äœ¿çšãéå§ããŸãã ããã§ã¯ãäœæãã2çªç®ã®ãŠãŒã¶ãŒã䜿çšããŸãã ãã¹ãŠãããã§èª¬æãããŠããŸã-http://community.igniterealtime.org/docs/DOC-1060
ãã¹ãŠãããå°ãè€éã§ãèœãšãç©ŽããããŸãã äž»ãªãã®-ã¬ãžã¹ããªã«ã€ããŠèŠããŠãã-ãã¹ãŠãéèŠã§ãã ããã¥ã¢ã«ã®ããã«æžããŸã-倧æåãå°æåãå°æåãå°æå ãµãŒããŒããã¡ã€ã³ã«å ¥åããå°å ¥ã®äºå®ã確èªããããšãå¿ããªãã§ãã ããã ããã¯éèŠã§ã!!!
ã¯ãããã¡ã€ã³ã³ã³ãããŒã©ãŒã§ããŒã¿ããäœæããŸãã-ãã¹ãŠãããŸããããŸããã JavaããŒã«ã¯äœ¿çšããŸããã§ããã
Spark-ãã€ãã£ãOpenFireã¯ã©ã€ã¢ã³ããã€ã³ã¹ããŒã«ããŸããSSOãæ©èœãããã©ããã確èªããŸãã ããã§ãªãå Žåã¯ãç解ããå¿ èŠããããŸã-èŠãŠãæžããŠãèŠãŠãã ããã
AsteriskãµãŒããŒã«ç§»åããŸãïŒå¿ããªãã§ãã ãã-ç§ã¯FreePbxãæã£ãŠããã®ã§ããã®ã¹ããŒã ã«é¢é£ãããã¡ã€ã«ã®ååãä»ããŸã;裞ã®Asteriskã®å Žåããã¹ãŠãå°ãç°¡åã«ãªããŸãïŒãOpenFireãŠãŒã¶ãŒmanager_custom.confã«æžã蟌ã¿ãŸãã
[openfire] secret = XXXX deny=0.0.0.0/0.0.0.0 permit=10.10.8.226/255.255.255.0 read = all write = all
次ã«ãAsterisk-IMãã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããŸãã ããã¯OpenFire Webã€ã³ã¿ãŒãã§ãŒã¹ã®ãå©çšå¯èœãªãã©ã°ã€ã³ã®ã¿ãã«ãããŸãã ç»å ŽããAsterisk-IMã¿ãã«VoIPãµãŒããŒãç»é²ããŸãã
Server Name: AsteriskGSeveren01 ServerAddress: 10.10.8.98 Port: 5038 Username: openfire Password: XXXX
ãŠãŒã¶ãŒãæã§åŠæ¹ããçªã§ã... [é»è©±ã®ãããã³ã°]ã¿ãã«ç§»åããŠãæžã蟌ã¿ãæžã蟌ã¿ãæžã蟌ã¿ãè¡ãå¿ èŠããããŸãã æ°äººã®ãŠãŒã¶ãŒã«éå®ããäœæ¥ã確èªããŸãã Sparkã®é£çµ¡å ãªã¹ãã§ããŠãŒã¶ãŒåãå³ã¯ãªãã¯ãããšãé話ãªãã·ã§ã³ã衚瀺ãããŸãã ãã³ãã»ãããæã¡äžãããšãã«ãããã€ã¹ã鳎ããªããã°ãªããŸãã-å å ¥è ã®ããã€ã¹ãéžæããŸãã
ãã¹ãŠãããŸãããã°ãããã ããã§ãªãå Žåã¯ãç解ããå¿ èŠããããŸã-èŠãŠãæžããŠãèŠãŠãã ããã
ä»ãã»ãšãã©ã®æéãè²»ããããã®ãå§ãŸããŸãã
ãã¡ã€ã³ãŠãŒã¶ãŒãååšããActive Directoryã«å¿ èŠãªãã¹ãŠã®æ å ±ãããããšãAsterisk-IMã«èª¬æããå¿ èŠããããŸãã
çŽæ¥-æ¹æ³ã¯ãããŸããã ãã©ã°ã€ã³ã¯å€ãããã®ãµããŒãã¯å»æ¢ãããŸãã-é£ã¹ãŠãã ããã ãããŠããã©ã°ã€ã³ããã®æ å ±ãä¿åããMySQLããŒã¿ããŒã¹ããããŸãã æãç°¡åãªæ¹æ³ã¯ãããŒã¿ããŒã¹ããOpenFireãŠãŒã¶ãŒã«é¢ããæ å ±ãæœåºããAsterisk-IMã§ããããããããšã§ãã ãã ãããšã³ãããŒãšã³ãèªèšŒããããããOpenFireã¯ããŒã¿ããŒã¹ã«äœãä¿åããŸããããã¡ã€ã³ã³ã³ãããŒã©ãŒããçŽæ¥ãã©ãã°ããŸãã
ããã LDAPãããã³ã«ïŒæ¢ã«ãŠãŒã¶ãŒãããïŒã䜿çšããŠADã«ããã¿ã€ããIMã°ã«ãŒãã®ã¡ã³ããŒã§ãããã¡ã€ã³ãŠãŒã¶ãŒã®æ å ±ããã©ãã°ãããã«ããŒã ããã°ã€ã³ãé»è©±çªå·ãå«ããã£ãŒã«ããåãåºãã¹ã¯ãªãããäœæããŸãã 次ã«ãSQLã€ã³ãžã§ã¯ã·ã§ã³ãäœæããAsterisk-IMããŒã¿ããŒã¹ã«çŽæ¥ããã·ã¥ããŸãã æããªæŸèæããããã¯åäœããŸãã
2ã€ã®ã¹ã¯ãªãããäœæãããŸããã1ã€ã¯ããã§æºåãã§ããŠããããšãããããŸãã ã ããã¯perlã§æžãããŠããŸã-ãã¡ã€ã³ããæ å ±ãååŸãããšããã§ãæå°éã®ç·šéåŸã«å®æããsip.confã衚瀺ããããšãã§ããŸãã bashã®2çªç®ã¯ãæåã®åŒã³åºããåŒã³åºããçµè«ãåæããŸãïŒã¯ããç§ã¯ç°åžžãªäººéã§ããããšã¯ç¥ã£ãŠããŸãããã¿ã¹ã¯ã¯æ¢ã«èª°ãã«ãã£ãŠè§£æ±ºãããŠããã®ã§ããã§ã³ã¹ããå¿ èŠã¯ãããŸããïŒãSQLã€ã³ãžã§ã¯ã·ã§ã³ãçæããããŒã¿ããŒã¹ã«ãã¹ãŠãæŒã蟌ã¿ãŸãã
users-from-AD.plã«ãã£ãŠèª€ã£ãŠå€æŽããã
#!/usr/bin/perl # users.pl v1.1 # # Script to generate asterisk 'users.conf' file from Active Directory (LADP) on users which contains 'phone' attribute # # Using: # 1. Print users to STDOUT: # users.pl # # 2. Print users to file: # users.pl users_custom.conf use strict; use warnings; use Net::LDAP; use Lingua::Translit; ###################### ### BEGIN SETTINGS ### ###################### my $debug = 0; my $warning = 0; # name of Domain my $AD="steepler.local"; # Domain name in format AD # for example mydomain.ru my $ADDC="DC=steepler,DC=local"; # user in Active directory # example: "CN=asterisk,CN=Users,$ADDC" my $ADUserBind="cn=openfire, cn=users, dc=steepler, dc=local"; my $ADpass="XXXXXXX"; # base search tree # example "OU=Users,$ADDC" my $ADUsersSearchBase="$ADDC"; # Field in active directory where telephone number, display name, phone stored # "telephonenumber", "displayname", "mail" my $ADfieldTelephone="telephonenumber"; my $ADfieldFullName="displayname"; my $ADfieldMail="mail"; my $ADfieldUser="samaccountname"; my $ADfieldGroup="memberOf"; my $ADSearchGroup="CN=IM,CN=Users,DC=steepler,DC=local"; # You need to create a dialplan in your asterisk server; my $dialplan="office"; # default settings my $user_static = "context = $dialplan call-limit = 100 type = friend registersip = no host = dynamic callgroup = 1 threewaycalling = no hasdirectory = no callwaiting = no hasmanager = no hasagent = no hassip = yes hasiax = yes nat=yes qualify=yes dtmfmode = rfc2833 insecure = no pickupgroup = 1 autoprov = no label = macaddress = linenumber = 1 LINEKEYS = 1 callcounter = yes disallow = all allow = ulaw,alaw,iLBC,h263,h263p "; ####################### ### END OF SETTINGS ### ####################### my $ldap; # get array DNS names of AD controllers my $dig = "dig -t srv _ldap._tcp.$AD" . '| grep -v "^;\|^$" | grep SRV | awk "{print \$8}"'; my @adControllers = `$dig`; # try connect to AD controllers foreach my $controller (@adControllers){ $controller =~ s/\n//; #INITIALIZING $ldap = Net::LDAP->new ( $controller ) or next; print STDERR "Connected to AD controller: $controller\n" if $debug > 0; last; } die "$@" unless $ldap; my $mesg = $ldap->bind ( dn=>$ADUserBind, password =>$ADpass); #PROCESSING - Displaying SEARCH Results # Accessing the data as if in a structure # ie Using the "as_struct" method my $ldapUsers = LDAPsearch ( $ADUsersSearchBase, "$ADfieldGroup=$ADSearchGroup", [ $ADfieldFullName, $ADfieldTelephone, $ADfieldMail, $ADfieldUser ] )->as_struct; # translit RUS module. # GOST 7.79 RUS, reversible, GOST 7.79:2000 (table B), Cyrillic to Latin, Russian my $tr = new Lingua::Translit("GOST 7.79 RUS"); my %hashPhones = (); my $phones = \%hashPhones; my @out; while ( my ($distinguishedName, $attrs) = each(%$ldapUsers) ) { # if not exist phone or name - skipping my $attrPhone = $attrs->{ "$ADfieldTelephone" } || next; my $attrUser = $attrs->{ "$ADfieldUser" } || next; my $attrName = $attrs->{ "$ADfieldFullName" } || next; my $encName = $tr->translit("@$attrName"); my $attrMail = $attrs->{ "$ADfieldMail" } || [""]; # check for duplicates phone number if ( $phones -> {"@$attrPhone"} ){ my $currUser = "@$attrName"; my $existUser = $phones -> {"@$attrPhone"}; print STDERR "@$attrPhone alredy exist! Exist:'$existUser' Current:'$currUser'... skipping - '[@$attrPhone] $currUser'\n" if $warning; next; } else { $phones -> {"@$attrPhone"} = "@$attrName"; } # password for SID = (telephonenumber without first digit) + 1 # example: phone=6232 pass=233 #$phsecret =sprintf("%03d",( substr("@$attrVal",1,100)+1)); my $phsecret = "@$attrPhone"; my $lcuser = "@$attrUser"; $lcuser = lc($lcuser); push (@out, "@$attrPhone " . "$lcuser " . "$encName\n" ); } # End of that DN # print to file if (@ARGV){ open FILE, "> $ARGV[0]" or die "Error create file '$ARGV[0]': $!"; print STDOUT "Printing to file '$ARGV[0]'"; print FILE @out; close FILE; print STDOUT " ...done!\n"; } # print to STDOUT else{ print @out; } exit 0; #OPERATION - Generating a SEARCH #$base, $searchString, $attrsArray sub LDAPsearch { my ($base, $searchString, $attrs) = @_; my $ret = $ldap->search ( base => $base, scope => "sub", filter => $searchString, attrs => $attrs ); LDAPerror("LDAPsearch", $ret) && die if( $ret->code ); return $ret; } sub LDAPerror { my ($from, $mesg) = @_; my $err = "[$from] - error" ."\nCode: " . $mesg->code ."\nError: " . $mesg->error . " (" . $mesg->error_name . ")" ."\nDescripton: " . $mesg->error_desc . ". " . $mesg->error_text; print STDERR $err if $warning; }
ãããŠãbashã®2çªç®ã®ãã®ã§ãã
phone-bindings-update-from-AD.sh ïŒ
#!/bin/bash TIMESTAMP=`/bin/date +%d%m%y%k%M%S` BACKUPDIR=/opt/openfire/bin/phone-mappings/backup BINDIR=/opt/openfire/bin WORKDIR=$BINDIR/phone-mappings SCRIPTNAMEDEVICE=$WORKDIR/phone-bindings-from-AD-device.sql SCRIPTNAMEUSER=$WORKDIR/phone-bindings-from-AD-user.sql SCRIPT=$WORKDIR/$SCRIPTNAME PERLSCRIPT=$BINDIR/users-from-AD.pl DEVICETPLHEAD=$WORKDIR/phoneDevice.tplhead DEVICEINJ=$WORKDIR/phoneDevice.inj DEVICETPLFOOT=$WORKDIR/phoneDevice.tplfoot USERTPLHEAD=$WORKDIR/phoneUser.tplhead USERINJ=$WORKDIR/phoneUser.inj USERTPLFOOT=$WORKDIR/phoneUser.tplfoot #backuping tables mysqldump -uXXXXXXX -pXXXXXXX openfire phoneDevice > $BACKUPDIR/phoneDevice-$TIMESTAMP.sql mysqldump -uXXXXXXX -XXXXXXX openfire phoneUser > $BACKUPDIR/phoneUser-$TIMESTAMP.sql # Clearing injections cat /dev/null > $DEVICEINJ cat /dev/null > $USERINJ # finding current Asterisk server ID in openfire DB serverID=`mysql -Bse "SELECT serverID FROM openfire.phoneServer;" -uXXXX -pXXXX` # resetting counters counter=0 counter2=0 #executing perl script to retrieve current phone numbers from AD for i in `$PERLSCRIPT`; do counter=`expr $counter + 1` binder[$counter]=$i done maxcount=$counter counter=1 while [ "$counter" -lt "$maxcount" ] do # deviding array into two with extensions and jids counter2=`expr $counter2 + 1` extension=${binder[$counter]} counter=`expr $counter + 1` username=${binder[$counter]} counter=`expr $counter + 1` callerID=${binder[$counter]} counter=`expr $counter + 1` callerID=$callerID\ ${binder[$counter]} counter=`expr $counter + 1` deviceID=$counter2 userID=$counter2 # Creating phoneDevice injection echo INSERT INTO \`phoneDevice\` VALUES\($deviceID,\'SIP/$extension\',\'$extension\',\'$callerID\',1,$userID,$serverID\)\; >> $DEVICEINJ # Creating phoneUser injection echo INSERT INTO \`phoneUser\` VALUES\($userID,\'$username\'\)\; >> $USERINJ done # Compile complete injections cat $DEVICETPLHEAD > $SCRIPTNAMEDEVICE cat $DEVICEINJ >> $SCRIPTNAMEDEVICE cat $DEVICETPLFOOT >> $SCRIPTNAMEDEVICE # Compile complete injections cat $USERTPLHEAD > $SCRIPTNAMEUSER cat $USERINJ >> $SCRIPTNAMEUSER cat $USERTPLFOOT >> $SCRIPTNAMEUSER # Injecting into tables cat $SCRIPTNAMEDEVICE | mysql -uXXXXXXX -pXXXXXXX cat $SCRIPTNAMEUSER | mysql -uXXXXXXX âpXXXXXXX
ã芧ã®ãšããã2çªç®ã®ã¹ã¯ãªããã§ã¯ãæ³šå ¥ã®ããããŒãšããã¿ãŒã«ãã³ãã¬ãŒãã䜿çšããŠããŸãã ãã³ãã¬ãŒãã¯ãmysqldumpãæ¢åã®ããŒãã«ã«å¯ŸããŠå®è¡ããçµæãããªãã³ã°ããããšã«ããååŸãããŸãã å®éããã³ãã¬ãŒãã¯æ¬¡ã®ãšããã§ãã
phoneUser.tplheadïŒ
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; USE openfire; DROP TABLE IF EXISTS `phoneUser`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE phoneUser ( userID bigint not null, username varchar(255) not null unique, primary key (userID) ); SET character_set_client = @saved_cs_client; LOCK TABLES `phoneUser` WRITE; /*!40000 ALTER TABLE `phoneUser` DISABLE KEYS */;
phoneUser.tplfootïŒ
/*!40000 ALTER TABLE `phoneUser` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
phoneDevice.tplheadïŒ
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; USE openfire; DROP TABLE IF EXISTS `phoneDevice`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `phoneDevice` ( `deviceID` bigint(20) NOT NULL, `device` varchar(255) NOT NULL, `extension` varchar(255) NOT NULL, `callerId` varchar(255) default NULL, `isPrimary` int(11) NOT NULL, `userID` bigint(20) default NULL, `serverID` bigint(20) NOT NULL, PRIMARY KEY (`deviceID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; LOCK TABLES `phoneDevice` WRITE; /*!40000 ALTER TABLE `phoneDevice` DISABLE KEYS */;
phoneDevice.tplfootïŒ
/*!40000 ALTER TABLE `phoneDevice` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
ã¹ã¯ãªãããã¯ã©ãŠã³ã«ããã·ã¥ããå®è¡ããŠãAsterisk-IMãã©ã°ã€ã³ã®Phone Bindingsã¿ãã§é»è©±ã«ãã€ã³ããããŠãããŠãŒã¶ãŒãèŠã€ããŸãã ä»äºã®ååãå®äºããŸããã
次ã®ã¿ã¹ã¯ã¯ãäžåšçä¿¡ã¡ãã»ãŒãžãéä¿¡ããããšã§ãã TrixBoxãŸãã¯FreePBXã䜿çšããŠããå Žå-ç§ãšåãããã«-ãã¹ãŠãããããåäœããŸãã 裞ã®ã¢ã¹ã¿ãªã¹ã¯-ãã¹ãŠãããªãã®æã®äžã«ããå Žåãå³èã§ãããªããããããå©çšã§ããŸãã ç§ãéšåçã«ããããŸããïŒïŒïŒ
ãŸããããŒã䜿çšããŠsshçµç±ã§èªèšŒãå®è¡ããå¿ èŠããããŸã-scpãšãªã¢ãŒãããã·ãŒãžã£å®è¡ã䜿çšããŸãã ssh-keygenã圹ç«ã¡ãŸãããããã¯ãŒã¯äžã«ååãªããã¥ã¢ã«ããããŸããç¹°ãè¿ãã¯ããŸããã jabberãµãŒããŒäžã®ã¹ã¯ãªããã¯ãåã®ã¹ã¯ãªããã§ç·šéããããŒã¿ããŒã¹ã«ç§»åããŸãïŒã¯ãããããã1ã€ã«çµåããããšã¯ã§ããŸãããã¿ã¹ã¯ãåæã«è§£æ±ºã§ããŸããã§ããã ãé»è©±çªå·ã jIDãçæããŸãã 次ã«ãAsteriskçµã¿èŸŒã¿ããŒã¿ããŒã¹ã«æ å ±ãå ¥åãããããAsteriskãµãŒããŒã«è»¢éããŠå®è¡ããå®è¡å¯èœã¹ã¯ãªãããæºåããŸãã
èµ·ãã£ãããšã¯æ¬¡ã®ãšããã§ãã
phone-mapping-request.sh ïŒ
#!/bin/bash WORKDIR=/opt/openfire/bin/phone-mappings SCRIPTNAME=phone-mappings-script.sh SCRIPT=$WORKDIR/$SCRIPTNAME SERVER=jbrgseveren01.steepler.local #asterisk USER@HOST:/PathToFile ASTERISK=root@10.10.8.98 #asterisk /PathToFile RPATH=/etc/asterisk/scripts counter=0 counter2=0 #clearing script file cat /dev/null > $SCRIPT #perform MYSQL request for mappings for i in `mysql -Bse "SELECT extension,username FROM openfire.phoneDevice JOIN openfire.phoneUser ON openfire.phoneUser.UserID=openfire.phoneDevice.UserID;" -uXXXX -pXXXX`; do counter=`expr $counter + 1` mapper[$counter]=$i done maxcount=$counter counter=1 while [ "$counter" -lt "$maxcount" ] do # deviding array into two with extensions and jids counter2=`expr $counter2 + 1` extension[$counter2]=${mapper[$counter]} counter=`expr $counter + 1` jid[$counter2]=${mapper[$counter]} counter=`expr $counter + 1` # forming asterisk script outstringdel="asterisk -rvx \"database del AMPUSER "${extension[$counter2]}"/jid\"" outstringadd="asterisk -rvx \"database put AMPUSER "${extension[$counter2]}"/jid "${jid[$counter2]}"@"$SERVER"\"" echo $outstringdel >> $SCRIPT echo $outstringadd >> $SCRIPT done # moving scrip to asterisk host chmod 755 $SCRIPT scp $SCRIPT $ASTERISK:$RPATH # run script ssh $ASTERISK $RPATH/$SCRIPTNAME
å°ããªããšã¯ããããã©ãããããã¢ã¹ã¿ãªã¹ã¯ã«èª¬æããããšã§ãã ããã§ã¯ããšã³ããªãã€ã³ãã®æ€çŽ¢ã«èšå€§ãªæéãè²»ããããŸããã ãããç§ã®ããã«æ©èœããå Žå-çµæ§ã§ãã ããã§ãªãå Žåãç§ã¯ãã³ããäžããŸãã ã¢ã¹ã¿ãªã¹ã¯ãåãæ¡ä»¶ã«å¯ŸããŠç°ãªãåœä»€ãå«ãŸããå ŽåïŒã€ãŸããæ¡ä»¶ã«å¯Ÿãã1ã€ã®ã¢ã¯ã·ã§ã³ããã€ã€ã«ãã©ã³ã«æžã蟌ãŸããå¥ã®åœä»€ãããŒããããã³ã³ããã¹ãããã®å å«ã«å«ãŸããå ŽåïŒãåœä»€ã«å¯ŸããŠæåã«åä¿¡ãããåœä»€ã䜿çšãããŸãã ãã®åŸã®æããªç¡èŠã ã€ãŸããäœããã®é¢æ°ãäœæããŠæ¿å ¥ããçµæããŒãã®å Žåããã€ã€ã«ãã©ã³ã衚瀺ããŠããã®ã³ã³ããã¹ããã©ã³ãã§ãã®æ¡ä»¶ãçºçããå Žæããã¹ãŠã®ã€ã³ã¯ã«ãŒãã®åã«ç¢ºèªããŸãã
ç§ã®å Žåã extensions_custom.confã«è¿œå ããã®ã«ååã§ããããšãå€æããŸããïŒ
[from-internal-noxfer-custom] ; Missed calls Jabber notification exten => h,1,Macro(XMPPSend,) exten => h,n,Macro(hangupcall) [macro-XMPPSend] ; Missed calls Jabber notification exten => s,1,GotoIf($["foo${DB(AMPUSER/${THISDIAL:4}/jid)}" = "foo"]?5:2) exten => s,n,Set(JID=${DB(AMPUSER/${THISDIAL:4}/jid)}) exten => s,n,Jabbersend(asterisk-jabber,${JID},${STRFTIME(${EPOCH},,%d/%m/%Y-%H:%M:%S)} - ${THISDIAL:4} ${CALLERID(name)}, ${CALLERID(num)}) exten => s,n,MacroExit() exten => s,n,Noop(No Jabber ID provided for target extension - ${THISDIAL:4}) exten => s,n,MacroExit()
ãããŠãAsteriskãOpenFireã®ã³ã³ããŒãã³ããšããŠç»é²ããŸãã
ã¢ã¹ã¿ãªã¹ã¯ã®åŽé¢ïŒ
Jabber.confïŒ
[general] debug=no ;;Turn on debugging by default. ;autoprune=yes ;;Auto remove users from buddy list. ;autoregister=yes ;;Auto register users from buddy list. [asterisk-jabber] ;;label type=component ;;Client or Component connection serverhost=jbrgseveren01.steepler.local ;;Route to server username=asterisk ;;Username with optional roster. secret=XXXX ;;Password port=5275 ;;Port to use defaults to 5222
OpenFireåŽã§ããµãŒããŒ->ãµãŒããŒèšå®->å€éšã³ã³ããŒãã³ãèšå®ã«ç§»åããŸã
ãµãŒãã¹æå¹ãæå¹ã«ããŸãã å¿ èŠã«å¿ããŠããã¯ã€ããªã¹ãã«ã¢ã¹ã¿ãªã¹ã¯ãè¿œå ããŸãã
ãµãŒãã¹ã®ç¢ºèª...
äœãã圹ã«ç«ãŠã°å¹žãã§ãã 質åãããã°-æžããŠãã ããã