Page 1 of 1 1
Topic Options
#190756 - 2008-11-25 04:23 PM VPN script should query userprofile
Dynamite Dan Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 20
Loc: België
Hi,

i'm calling from my VPN client separate script other then the normal logon script in the user profile.
Because the connecting pc's have multipli ip-addresses i use this FindLANaddress function to query from where the client is starting the script.
I also use the Ping function to test connectivity to the server.

 Code:
Function FindLANaddress($AddressToFind)
	$nul=setoption("NoMacrosinstrings","on")
	$nul=setoption("NoVarsinstrings","on")
	For $i = 0 to 5
   $ret = execute("$IP=@IPADDRESS" + $i)
   If InStr($IP,$AddressToFind)
		$FindLANaddress = $IP
   EndIf
	Next
	$nul=setoption("NoMacrosinstrings","OFF")
	$nul=setoption("NoVarsinstrings","OFF")
EndFunction

Function Ping($CompIP, optional $Logout)
	$Count = 6000
	DO
		SHELL '%Comspec% /C ping -n 1 ' + $CompIP + ' | find /C "10.30" > nul'				
		IF ( @error = 0 AND NOT $Logout) OR (@error = 1 and $Logout)
			$Ping = 1					
			EXIT 0			
		ENDIF			
		SLEEP 1
	$Count = $Count -1
	UNTIL $Count = 0
EndFunction


Main program:
 Code:
$ServerToPing = "Server1"
IF Ping($ServerToPing) = 1 AND FindLANaddress("10. 90.  7") 
...


and then i should query the AD user profile for the logon script setting.
There are 4 different sites that use a separate script, however when users are at another site they should get there default script (cfr user profile) and not the script linked to the sites.

I found already this part on the site however i'm not able to select the "login script" parameter because i don't know the syntax.
where could find a list of the $objUser.xxxx parameters?

 Code:
$objSysInfo = CreateObject("ADSystemInfo") 
$strComputerDN = $objSysInfo.computerName 
$strUserDN = $objSysInfo.userName 

$strUserOU=Split($strUserDN,"OU=")
$strUserOU[0]=""
$strUserOU=Join($strUserOU,"OU=")

$strComputerOU=Split($strComputerDN,"OU=")
$strComputerOU[0]=""
$strComputerOU=Join($strComputerOU,"OU=")


"Information from ADSystemInfo"+@CRLF
"-----------------------------"+@CRLF
"           User DN: "+$strUserDN+@CRLF
"    User container: "+$strUserOU+@CRLF
"       Computer DN: "+$strComputerDN+@CRLF
"Computer container: "+$strComputerOU+@CRLF
@CRLF

"Information from AD User & Computer objects"+@CRLF
"-------------------------------------------"+@CRLF
$objComputer = GetObject("LDAP://" + $strComputerDN)
$objUser = GetObject("LDAP://" + $strUserDN)

"           User cn: "+$objUser.cn+@CRLF
"         User mail: "+$objUser.mail+@CRLF
"       Computer OS: "+$objComputer.operatingSystem+@CRLF


Edited by Benny69 (2008-11-25 05:27 PM)
Edit Reason: I added Code Tags

Top
#190757 - 2008-11-25 07:52 PM Re: VPN script should query userprofile [Re: Dynamite Dan]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Get an LDAP browser and look at the properties (and objects) that are available in AD.

You will find that .mail is not a valid property and is actually an object.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#190759 - 2008-11-25 09:49 PM Re: VPN script should query userprofile [Re: Gargoyle]
Dynamite Dan Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 20
Loc: België
Great tip

found now that this line gives me the result i want
GetObject("LDAP://" + CreateObject("ADSystemInfo").userName).scriptPath

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 405 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.052 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org