<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">After a bit of work, I was able to solve it by running a php script in the preacct process.<div><br></div><div>I added the external program with exec:</div><div><br></div><div><div>exec 1stlogin {</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>wait = yes</div><div> program = "/usr/bin/php /root/1stlogin.php %{User-Name} %{Calling-Station-Id}"</div><div> input_pairs = request</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><br></div><div>Then in the preacct session I added</div><div><span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"> </span>1stlogin</div><div><br></div><div>The script itself as follows:</div><div><br></div><div><div><?php</div><div>$link = mysql_connect('localhost', 'root', 'xxxxxx');</div><div>if (!$link) {</div><div> die('Could not connect: ' . mysql_error());</div><div>}</div><div>mysql_select_db('radius');</div><div>$result=mysql_query("SELECT * FROM radacct WHERE `UserName`='$argv[1]' order by Username limit 1");</div><div>$val = mysql_num_rows($result);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if ($val > 0) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>printf ("Not first auth"); </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>else {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>mysql_query("INSERT into radcheck (UserName, Attribute, op, Value) values ('$argv[1]', 'Calling-Station-Id', '==', '$argv[2]')");<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div><br></div><div>?></div><div><br></div><div><br></div><div>I rarely write any php, so any improvement in the code is highly appreciated. Do I need to return anything to freeradius in case of an error or something?</div><div><br></div><div>Cheers,</div><div>Kledi</div><div><br></div><div><br></div></div><div><br></div><div><div>On Feb 13, 2010, at 3:01 AM, <a href="http://EasyHorpak.com">EasyHorpak.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
Kledi Andoni wrote:
<blockquote cite="mid:E98A2957-59CB-420E-8D1B-DC3AAE3DE6A5@pronet.com.al" type="cite">
<pre wrap="">Hello,
I need a way to set the Calling-Station-Id attribute automatically for each user after the first authorization request. In this way the user will be allowed to authorize only from that mac address in the future.
I am using freeradius 1.1.7 with mysql. I do not have the expertise to write a new module, but I believe the way to do it is:
- User tries to authorize and sends username/password/calling-station-id
- Radius verifies username/password (calling-station-id is not yet set)
- Check if a user has ever authorized, through a query on the radacct table. If no rows exist for the specific username then its first login
- insert a row containing the calling-station-id for the specific user in the radcheck table.
Is there a way to do this by configuring freeradius, or do I have to submit it as a request for a feature?
Thank you,
K
-
List info/subscribe/unsubscribe? See <a class="moz-txt-link-freetext" href="http://www.freeradius.org/list/users.html">http://www.freeradius.org/list/users.html</a>
</pre>
</blockquote>
you can use modules checkval to make calling-station-id check.<br>
But for add calling-station-id on first login, you need more scripts to
add it.<br>
you may use unlang. for me i use pppoe-server as nas. i use php to add
it after first login.<br>
<br>
<div class="moz-signature">-- <br>
<a href="http://www.EasyHorpak.com/" target="_blank">http://www.EasyHorpak.com</a>
- แหล่งค้นหาหอพัก,อพาร์ทเมนท์,แมนชั่น,คอนโด,โรงแรม<br>
<a href="http://www.EasyZoneCorp.net/" target="_blank">http://www.EasyZoneCorp.net</a>
- ซอฟแวร์จัดการ internet คุณภาพสูง Hotpsot และ PPPoE ,Anti NetCut, Mac
spoof<br>
<a href="http://www.thai-school.net/" target="_blank">http://www.thai-school.net</a>
- เว็บไซต์โรงเรียน,ศิษย์เก่า สำเร็จรูป <br>
<a href="http://www.easyhorpak.com/superlink" target="_blank">EasyZone
SuperLink </a> - แลกหมื่นลิ้งคืในคลิ๊กเดียว <br>
</div>
</div>
-<br>List info/subscribe/unsubscribe? See <a href="http://www.freeradius.org/list/users.html">http://www.freeradius.org/list/users.html</a></blockquote></div><br></div></body></html>