<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Routing and Remote Access Blog : Admin dll</title><link>http://blogs.technet.com/rrasblog/archive/tags/Admin+dll/default.aspx</link><description>Tags: Admin dll</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Limit one connection to the VPN server per user</title><link>http://blogs.technet.com/rrasblog/archive/2008/07/17/limit-one-connection-to-the-vpn-server-per-user.aspx</link><pubDate>Thu, 17 Jul 2008 14:30:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3090125</guid><dc:creator>rrasblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/rrasblog/comments/3090125.aspx</comments><wfw:commentRss>http://blogs.technet.com/rrasblog/commentrss.aspx?PostID=3090125</wfw:commentRss><description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I thought it would be worthwhile to blog a post specifically on this topic. I've seen quite a number of people having this requirement to limit the number of VPN connections that can be made to the VPN server using a particular username to just one. And I did take this one as the example program in my earlier post about developing a RAS administration DLL. However, I thought it would be good to elaborate a little more on what the DLL actually does.&lt;/P&gt;
&lt;P&gt;You can refer to the code (attached as a rtf file) in this post --&amp;gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/rrasblog/archive/2007/12/20/steps-to-develop-a-ras-administration-dll-using-visual-studio.aspx" mce_href="http://blogs.technet.com/rrasblog/archive/2007/12/20/steps-to-develop-a-ras-administration-dll-using-visual-studio.aspx"&gt;http://blogs.technet.com/rrasblog/archive/2007/12/20/steps-to-develop-a-ras-administration-dll-using-visual-studio.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Among all the callback functions that we have implemented, the two important ones to consider are &lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;MprAdminConnectionHangupNotification2 and &lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;MprAdminAcceptNewConnection2. &lt;FONT face=Arial&gt;These are the functions where we do processing when there is a client connection/disconnection coming.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;FONT face=Arial&gt;Let's the take MprAdminAcceptNewConnection2 first. This function has the below prototype&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;BOOL WINAPI &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;MprAdminAcceptNewConnection2(RAS_CONNECTION_0 * pRasConnection0,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RAS_CONNECTION_1 * pRasConnection1,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RAS_CONNECTION_2 * pRasConnection2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;FONT face=Arial&gt;When there is a connection coming from the client, this callback is called with the parameters populated. Let's use the pRasConnection2 parameter for our processing. This structure RAS_CONNECTION_2 has the following format:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;typedef struct _RAS_CONNECTION_2 {&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;HANDLE &lt;SPAN style="mso-field-code: ' HYPERLINK '''"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;FONT color=#0000ff&gt;hConnection&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;WCHAR &lt;SPAN style="mso-field-code: ' HYPERLINK '''"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;FONT color=#0000ff&gt;wszUserName&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;[UNLEN + 1];&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;ROUTER_INTERFACE_TYPE &lt;SPAN style="mso-field-code: ' HYPERLINK '''"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;FONT color=#0000ff&gt;dwInterfaceType&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;GUID &lt;SPAN style="mso-field-code: ' HYPERLINK '''"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;FONT color=#0000ff&gt;guid&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;PPP_INFO_2 &lt;SPAN style="mso-field-code: ' HYPERLINK '''"&gt;&lt;SPAN class=MsoHyperlink&gt;&lt;FONT color=#0000ff&gt;PppInfo2&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;} RAS_CONNECTION_2, &lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;*PRAS_CONNECTION_2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The wszUserName parameter here is the one that is of interest to us here.&lt;o:p&gt;&amp;nbsp;This contains the name of the user who is connecting. We want to ensure that if there is already an active connection on this server from this user, this connection should be refused. So we need to do some book-keeping to keep track of the users who have an active connection on the server currently.&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;For this we maintain a linked list in this example. When a client connects, we check if the username already exists in the list. If yes, we reject the connection, else we allow the connection to go through and add the username to the list.&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;When a connection is disconnected, the callback &lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;MprAdminConnectionHangupNotification2 &lt;FONT size=3 face=Calibri&gt;is called. This function's prototype is as below:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;VOID WINAPI &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;MprAdminConnectionHangupNotification2(RAS_CONNECTION_0 * pRasConnection0,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RAS_CONNECTION_1 * pRasConnection1,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-pagination: none; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US" lang=EN-US&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RAS_CONNECTION_2 * pRasConnection2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Again&amp;nbsp;here,&amp;nbsp;we get the username from the pRasConnection2 structure&amp;nbsp;and delete that user from the list.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Coming to the implementation in detail, you can see that we are keeping track of the user's security identifiers&amp;nbsp;(SID) rather than the name itself. This is because a username can be represented in many ways - DOMAIN\USER, &lt;A href="mailto:USER@DOMAIN" mce_href="mailto:USER@DOMAIN"&gt;USER@DOMAIN&lt;/A&gt; etc. However, the SID is the same across. So we convert the username to user SID and store it in the list that we maintain.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Apart from this, during the DLL initialization, we also create a log file for debugging.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The linked list is just to explain the logic of how this is accomplished using administration DLL. However, we can use better ways of storing this information so that a look up is easy thereby ensuring lesser delay during connection.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Hope this helps. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Let us know if you would like to hear about something specific. Drop us a line at &lt;A href="mailto:rrasblog@online.microsoft.com" mce_href="mailto:rrasblog@online.microsoft.com"&gt;rrasblog@online.microsoft.com&lt;/A&gt; **&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;** Remove the online from the email ID to actually mail us.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Janani Vasudevan &lt;BR&gt;Software Design Engineer/Test &lt;BR&gt;RRAS, Windows Enterprise Networking&lt;/P&gt;
&lt;P&gt;[This posting is provided "AS IS" with no warranties, and confers no rights.]&lt;/P&gt;
&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-theme-font: minor-fareast; mso-fareast-language: EN-IN; mso-bidi-language: AR-SA" lang=EN-US&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;SCRIPT type=text/javascript&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/SCRIPT&gt;

&lt;SCRIPT type=text/javascript&gt;
try {
var pageTracker = _gat._getTracker("UA-1700161-11");
pageTracker._trackPageview();
} catch(err) {}&lt;/SCRIPT&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3090125" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rrasblog/archive/tags/Admin+dll/default.aspx">Admin dll</category></item><item><title>Steps to develop a RAS administration DLL using Visual Studio</title><link>http://blogs.technet.com/rrasblog/archive/2007/12/20/steps-to-develop-a-ras-administration-dll-using-visual-studio.aspx</link><pubDate>Thu, 20 Dec 2007 14:39:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2663032</guid><dc:creator>rrasblog</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.technet.com/rrasblog/comments/2663032.aspx</comments><wfw:commentRss>http://blogs.technet.com/rrasblog/commentrss.aspx?PostID=2663032</wfw:commentRss><description>&lt;P&gt;Hello folks! We saw how useful a RAS administration DLL can be to admins who want to control what the RRAS server does. In this post, let us see how we can develop a RAS administration DLL using Visual Studio.&lt;/P&gt;
&lt;P&gt;I have often seen requirements from admins to control the VPN server such that only one VPN connection can be made to a server using a single user name. This is basically to prevent users from distributing their usernames and hence resulting in lot of connections with the same username. So let us design and write a RAS administration DLL for this purpose.&lt;/P&gt;
&lt;P&gt;Let us call it RestrictOneConnPerUser.dll.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Pre-requisites:&lt;/U&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Microsoft Visual Studio 2005 &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;U&gt;Start building the RAS administration DLL &lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1) &lt;STRONG&gt;&lt;U&gt;Create New Project:&lt;/U&gt;&lt;/STRONG&gt; Open Microsoft Visual Studio and create a new project. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/solnopern_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/solnopern_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=solnopern src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/solnopern_thumb.jpg" width=428 height=239 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/solnopern_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;2) &lt;STRONG&gt;&lt;U&gt;Select Project type:&lt;/U&gt;&lt;/STRONG&gt; When you are asked to select the type of project, select Visual ++ --&amp;gt; Win32 --&amp;gt; Win32 Project. Type the name of the project as 'RestrictOneConnPerUser' and click on 'OK'.&lt;/P&gt;
&lt;P&gt;Note down the location that is given in the 'Location' drop down. Your project would be created at this location. So the source files for your project will have to be copied to the &lt;STRONG&gt;C:\Users\User1\Documents\Visual Studio 2005\Projects\RestrictOneConnPerUser&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/newprojdll_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/newprojdll_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=newprojdll src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/newprojdll_thumb.jpg" width=431 height=288 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/newprojdll_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) &lt;STRONG&gt;&lt;U&gt;Choose Project Options:&lt;/U&gt;&lt;/STRONG&gt; In the Win32 project type selection wizard that follows, select 'DLL' as the project type and choose 'Empty project'. Click on 'Finish'. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj1_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj1_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=proj1 src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj1_thumb.jpg" width=399 height=281 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj2_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj2_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=proj2 src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj2_thumb.jpg" width=401 height=281 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/proj2_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;4) &lt;STRONG&gt;&lt;U&gt;Write code:&lt;/U&gt;&lt;/STRONG&gt; Now, we have created a DLL project. The next step to add the code. Let's do that now. Download the file which is provided as attachment to this post. The file has the code for three files - the header file, the C source and the exports definition file - for the DLL.&lt;/P&gt;
&lt;P&gt;Click on Start --&amp;gt; Run --&amp;gt; Type 'notepad' --&amp;gt; Copy all the contents from the attached doc under 'UserRestrict.h' to the notepad and Save the file as 'UserRestrict.h'&lt;/P&gt;
&lt;P&gt;Similarly, open new notepad files, paste the contents of&amp;nbsp; 'UserRestrict.c' and 'UserRestrict.def' and save them with the names 'UserRestrict.c' and 'UserRestrict.def'.&lt;/P&gt;
&lt;P&gt;Now, copy all these three files to the project location, which would be &lt;STRONG&gt;C:\Users\User1\Documents\Visual Studio 2005\Projects\RestrictOneConnPerUser&lt;/STRONG&gt; for us now.&lt;/P&gt;
&lt;P&gt;5) &lt;STRONG&gt;&lt;U&gt;Include code files in project:&lt;/U&gt;&lt;/STRONG&gt; Once the code has been written, it then has to be included in the Project. The below snapshot will show you how to do it.&lt;/P&gt;
&lt;P&gt;Right click on the project --&amp;gt; Add --&amp;gt; Existing Item --&amp;gt; Browse to the solution directory which is &lt;STRONG&gt;C:\Users\User1\Documents\Visual Studio 2005\Projects\RestrictOneConnPerUser&lt;/STRONG&gt;. Select the file and add it to the project. Do this for the header and the C file. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hdrexisitem_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hdrexisitem_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=hdrexisitem src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hdrexisitem_thumb.jpg" width=302 height=300 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hdrexisitem_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hfileexisting_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hfileexisting_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=hfileexisting src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hfileexisting_thumb.jpg" width=399 height=258 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/hfileexisting_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexisting_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexisting_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=cfileexisting src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexisting_thumb.jpg" width=267 height=315 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexisting_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexistingselect_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexistingselect_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=cfileexistingselect src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexistingselect_thumb.jpg" width=419 height=270 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/cfileexistingselect_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;6) &lt;STRONG&gt;&lt;U&gt;Edit Project Properties:&lt;/U&gt;&lt;/STRONG&gt; Now, we have created the project, added the code. The only thing left now is to build it and get our DLL! Ok, before that we would need to edit some project properties - to include additional libraries that this code needs, to specify that you want a C file like compilation (not C++) etc.&lt;/P&gt;
&lt;P&gt;The steps that you would need to follow are outlined by the snapshots below:&lt;/P&gt;
&lt;P&gt;Open the project properties by right clicking on the Project --&amp;gt; Select Properties. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/projprop_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/projprop_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=projprop src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/projprop_thumb.jpg" width=226 height=291 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/projprop_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This will open up a window as below. Browse to 'Linker' --&amp;gt; 'Input' in the left hand side tree. You will the options like 'Additional dependencies' , 'Ignore all default libraries' etc. on the right hand side. This is how it will look for the project we created.&lt;/P&gt;
&lt;P&gt;We would be adding 'Additional dependencies' and the 'Module Definition File' for our project. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibs_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibs_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=defandlibs src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibs_thumb.jpg" width=410 height=299 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibs_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The below snapshot shows the additional dependency libraries that we need to add and the module definition file. The module definition file is nothing but the .DEF file that we created and copied to the solution folder in Step 4 above.&lt;/P&gt;
&lt;P&gt;Once you have added the libraries and modified the module definition file, click on 'Apply' to save the settings. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibsdone_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibsdone_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=defandlibsdone src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibsdone_thumb.jpg" width=415 height=282 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/defandlibsdone_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;There's just one more property that we would like to change i.e. to instruct the compiler to compile this as a C code. This is done by browsing to the 'Configuration Properties' --&amp;gt; C/C++ --&amp;gt; Advanced on the left pane. Then, edit the option 'Compile As' on the right pane and select 'Compile as C code (/TC)' from the dropdown list. Click on 'Apply' to save the settings.&lt;/P&gt;
&lt;P&gt;We are done with editing the project properties. So you can click 'OK' to go back to the project.&lt;/P&gt;
&lt;P&gt;The below snapshots will help illustrate this. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/compileasc_4.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/compileasc_4.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=compileasc src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/compileasc_thumb_1.jpg" width=429 height=270 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/compileasc_thumb_1.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;7) &lt;STRONG&gt;&lt;U&gt;Build the code: &lt;/U&gt;&lt;/STRONG&gt;We are all ready to build the code now. Right click on the Project --&amp;gt; click on 'Build Solution'. If everything goes well, you will see that the build succeeded and the DLL is present in the binaries location. For us, the binaries location would be &lt;STRONG&gt;C:\Users\User1\Documents\Visual Studio 2005\Projects\RestrictOneConnPerUser\Debug.&lt;/STRONG&gt; You will find the DLL &lt;STRONG&gt;RestrictOneConnPerUser.dll&lt;/STRONG&gt; here.&lt;/P&gt;
&lt;P&gt;Here we are!! Our own admin DLL is ready. We just have to deploy this on the RRAS server as per the deployment guidelines in MSDN. You can refer to it &lt;A href="http://msdn2.microsoft.com/en-us/library/aa377858(VS.85).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa377858(VS.85).aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/build_2.jpg" mce_href="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/build_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border=0 alt=build src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/build_thumb.jpg" width=244 height=116 mce_src="http://blogs.technet.com/blogfiles/rrasblog/WindowsLiveWriter/test_E49C/build_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Folks - That's it for now. I'll come back with another post explaining what the code actually does to restrict only one connection per user. Feel free to post any comments/queries to &lt;A href="mailto:rrasblog@online.microsoft.com" mce_href="mailto:rrasblog@online.microsoft.com"&gt;rrasblog@online.microsoft.com&lt;/A&gt;**&lt;/P&gt;
&lt;P&gt;**Remove the 'online.' from the mail ID above to actually mail us.&lt;/P&gt;
&lt;P&gt;Janani Vasudevan &lt;BR&gt;Software Design Engineer/Test &lt;BR&gt;RRAS, Windows Enterprise Networking&lt;/P&gt;
&lt;P&gt;[This posting is provided "AS IS" with no warranties, and confers no rights.]&lt;/P&gt;
&lt;SCRIPT type=text/javascript&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/SCRIPT&gt;

&lt;SCRIPT type=text/javascript&gt;
try {
var pageTracker = _gat._getTracker("UA-1700161-11");
pageTracker._trackPageview();
} catch(err) {}&lt;/SCRIPT&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2663032" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/rrasblog/attachment/2663032.ashx" length="16890" type="application/msword" /><category domain="http://blogs.technet.com/rrasblog/archive/tags/Admin+dll/default.aspx">Admin dll</category></item><item><title>RAS Administration DLL - Your customized solution to manage the server!</title><link>http://blogs.technet.com/rrasblog/archive/2007/12/16/ras-administration-dll-your-customized-solution-to-manage-the-server.aspx</link><pubDate>Sun, 16 Dec 2007 19:53:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2651707</guid><dc:creator>rrasblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/rrasblog/comments/2651707.aspx</comments><wfw:commentRss>http://blogs.technet.com/rrasblog/commentrss.aspx?PostID=2651707</wfw:commentRss><description>&lt;P&gt;Hello everyone. I understand that all of you would be busy checking out Vista and its cool features. However, for this post I decided to write about something which is very powerful but is little known - RAS administration DLL. The post will outline the use of a RAS administration DLL and will touch upon the basics of how to start writing your own customized RAS administration DLL.&lt;/P&gt;
&lt;P&gt;The admin DLL or the RAS administration DLL is loaded by RRAS during service startup. During service startup, the &lt;A href="http://msdn2.microsoft.com/en-us/library/aa374571.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa374571.aspx"&gt;&lt;STRONG&gt;MprAdminInitializeDll&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;function of the admin DLL is called. And during service shutdown, &lt;A href="http://msdn2.microsoft.com/en-us/library/aa375849.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa375849.aspx"&gt;&lt;STRONG&gt;MprAdminTerminateDll&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;is called.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;When would you use a RAS administration DLL?&lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;When you want to control the connection to the RRAS server based on either the user who connects, or the port on which the user connects or any other property of the connection or if you want to assign an IP address of your choice to the connecting client or if you just want to audit/log the connection information for your later reference, and if RRAS inherently doesn't support it, then it is time to write your own admin DLL to do what you require. Some typicaly scenarios which would require to have a RAS administration DLL are - to ensure that there can be only one VPN connection from a particular user, to ensure that particular users not be allowed to connect, to ensure that all connections of a particular media type be rejected etc.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;How would you start writing your own RAS administration DLL?&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;A RAS administration DLL must implement and export all of the following functions:&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa374554.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa374554.aspx"&gt;MprAdminAcceptNewLink&lt;/A&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa374571.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa374571.aspx"&gt;MprAdminInitializeDll&lt;/A&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa374596.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa374596.aspx"&gt;MprAdminLinkHangupNotification&lt;/A&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/aa375849.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa375849.aspx"&gt;MprAdminTerminateDll&lt;/A&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Typically, you will write three files, say, MyRasAdminDLL.h (which contains the #includes,#defines anddatastructures that you might use in the code), MyRasAdminDLL.cpp (which implements all these above functions) and MyRASAdminDLL.def (which is the module definition file for the DLL and would export all of the above functions and anything else that you would implement)&lt;/P&gt;
&lt;P&gt;In case, you do not want to implement any&amp;nbsp;these functions, just return TRUE or return as the function requires.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The complete list of Admin callback functions that you can implement is available &lt;A href="http://msdn2.microsoft.com/en-us/library/aa378053.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa378053.aspx"&gt;here&lt;/A&gt;. (Be careful to note the operating system that supports the functions and use accordingly)&lt;/P&gt;
&lt;P&gt;In the next post, we will see how to develop a RAS administration DLL using Visual Studio. See you soon!&lt;/P&gt;
&lt;P mce_keep="true"&gt;Janani Vasudevan&lt;BR&gt;Software Design Engineer/Test&lt;BR&gt;RRAS, Windows Enterprise Networking&lt;/P&gt;
&lt;P mce_keep="true"&gt;[This posting is provided "AS IS" with no warranties, and confers no rights.]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;SCRIPT type=text/javascript&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/SCRIPT&gt;

&lt;SCRIPT type=text/javascript&gt;
try {
var pageTracker = _gat._getTracker("UA-1700161-11");
pageTracker._trackPageview();
} catch(err) {}&lt;/SCRIPT&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2651707" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/rrasblog/archive/tags/Admin+dll/default.aspx">Admin dll</category></item></channel></rss>