PDA

View Full Version : Static IPs for RAS Users (W2K)



g707
02-09-2004, 12:27 PM
Not sure if this is the correct forum for this question, but no harm in posting:

I need to list the static IPs for our RAS user into a web page, (Active Directory 2000)
I determined the ADSI attribute as:
msRASSavedFramedIPAddress

Problem is the result is an integer value, maybe hex? I need to figure out how to convert and display the value as most normal people at used to seeing: x.x.x.x (ex. 192.168.0.1)

Any ideas?
Using ASP, ADSI, VBSCRIPT
Here the sample code I have so far, taken from technet, any help to display as web page would be greatly appreicated.

intMsRASSavedFramedIPAddress = objUser.Get("msRASSavedFramedIPAddress")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "No static IP address assigned."
Err.Clear
Else
hexMsRASSavedFramedIPAddress = Hex(intMsRASSavedFramedIPAddress)
WScript.StdOut.Write "IP Address in Hex (msRASSavedFramedIPAddress): "
For i = 1 to 8 Step 2
If i < 6 Then
WScript.StdOut.Write Mid(hexMsRASSavedFramedIPAddress,i,2) & "."
Else
WScript.Echo Mid(hexMsRASSavedFramedIPAddress,i,2)
End If
Next

objUser.Get "msRADIUSFramedIPAddress"
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
WScript.Echo "Static IP address specified but not assigned."
Err.Clear
Else
WScript.Echo "Static IP Address assigned."
End If

End If



*******
* g707 *
*******<P ID="edit"><FONT class="small">Edited by g707 on 02/09/04 12:43.</FONT></P>

Brf
02-09-2004, 12:40 PM
div the number by 256 and take the remainder.

Repeat 2 times. The remainders are the octets reading from right to left, and the final quotient is the first octet.

g707
02-09-2004, 12:49 PM
Brf,
can you provide an example.
I am having trouble with the reminder in the calculation.
Thanks

*******
* g707 *
*******

Brf
02-09-2004, 01:04 PM
my_ip= 3232235521

dim temp1, temp2, o2, o3, o4

temp1=my_ip
temp2=int(temp1 / 256.0)
o4 = temp1 - temp2 * 256
temp1=temp2
'
temp2=int(temp1 / 256.0)
o3 = temp1 - temp2 * 256
temp1=temp2
'
temp2=int(temp1 / 256.0)
o2 = temp1 - temp2 * 256
temp1=temp2
'
msgbox(temp1 & "." & o2 & "." & o3 & "." & o4 )