Page 2 of 3 <123>
Topic Options
#185293 - 2008-02-12 07:54 PM Re: Kix+Forms+Active Directory [Re: duo]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Okay I just posted the updated version 1.1 of Glenn's SANITY UDF

SANITY UDF

Top
#185294 - 2008-02-12 07:56 PM Re: Kix+Forms+Active Directory [Re: duo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: duo
That gets us to an interesting point Glen, check out this line
 Code:
Use $drive: $share /user:$StringUsername /password:$StringPassword

There is definantly something wrong with this line. What is the proper syntax for this line with novarsinstrings on?
....


The line above is the proper format with no vars in strings on and off. There are no vars inside strings in that line. The variable can hold a string but the variables should not placed in between quotes for best practice kix scripting. One could argue about the : behind and after the variables though.

 Originally Posted By: duo

....
also what is the difference between $=novars in strings or $variable name=no vars in strings?


There is no difference other the length of the variable taking the return value of Setoption("NorVarsInStrings", "on or off"). $ is a valid name for a variable in kix. Maybe not the best choice but still valid.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185295 - 2008-02-12 08:05 PM Re: Kix+Forms+Active Directory [Re: duo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
 Code:
Use $drive: $share /user:$StringUsername /password:$StringPassword

My first concern is that Kix is seeing "$Drive:" and not "$Drive" + ":"

Not sure what you mean in your second Q - SetOption('NoVarsInStrings', 'On') is the only valid syntax, and basically is an interpreter directive that changes how Kix handles the presence of "$" between single or double quotes. With it "on", the "$" is an ordinary character, with it "off" (the default), Kix treats the "$" as the special character that identifies a variable name. The var name is terminated by whitespace and select special characters. I don't recall if ":" is one of those special terminators.

Up to my eyeballs at the moment - maybe someone else can suggest changes for the USE statement to get you going..

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185296 - 2008-02-12 08:44 PM Re: Kix+Forms+Active Directory [Re: duo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: duo

....

Final comment, This is where everything gets frustrating
....
This works,and there is no real difference between this, or how its executed from the login script. It collects the user/pass and maps the drive...so why does this work with one of the drives through login script, but not both, when this works with both.


How about reworking the CmdUserLogin_Click function to this? Does this give you better results? Also using drive B might be tricky. Drive A and B could be used for diskette drives. I would never use any drive letter below D for a drive mapping.

 Code:
Function CmdUserLogin_Click()

	If $TextBoxUsername.Text = ""
		$= $Form.MsgBox("You must specify a username before clicking LOGIN.", "Invalid Username")
		$TextBoxUsername.Text = $StringUsername
		Exit Sub
	Else
		$StringUsername = $TextBoxUsername.Text
	EndIf

	If $TextBoxPassword.Text = ""
		$= $Form.MsgBox("You must specify a password before clicking LOGIN.", "Invalid Password")
		$TextBoxPassword.Text = $StringPassword
		Exit Sub
	Else
		$StringPassword = $TextBoxPassword.Text
	EndIf


	$Form.Hide

	$drive="B:"
	$server="\\Qs1045n5m\"
	$share="Benefits"

	$share = $server + $share

	;? "variables are" $share $Stringusername $Stringpassword

	? "mapping " + $drive + " to " + $share
	Use $drive /Delete
	Use $drive + " " $share + " /user:" + $StringUsername + " /Password:" + $StringPassword
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185297 - 2008-02-12 09:25 PM Re: Kix+Forms+Active Directory [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Mart:

I probably would not do that on a workstation, but I know that our servers do not have any floppy drives, and map to A/B all of the time. You're right - if you do it, you should do it with care.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185298 - 2008-02-12 09:45 PM Re: Kix+Forms+Active Directory [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Going back a few posts...
 Code:
$Drive = 'd'
'Drive is ' $Drive: ?

... displays "Drive is"
This confirms that "$Drive:" and "$Drive" are two different variables. You'll need to specify it as $Drive + ':'.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185299 - 2008-02-12 11:25 PM Re: Kix+Forms+Active Directory [Re: Glenn Barnas]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
This just gets more interesting as we go along it seems. I didnt even think of the possibility of $drive: becoming a variable, but having difficulties with that made me change my ini file to be B:, F:, etc. Til tomorrow guys!
Top
#185300 - 2008-02-12 11:27 PM Re: Kix+Forms+Active Directory [Re: duo]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
I didn't like the idea of using A-H as drive letters for the record, B is the only one in this range I do utilize.
Top
#185316 - 2008-02-13 05:32 PM Re: Kix+Forms+Active Directory [Re: duo]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
Function CmdUserLogin_Click()

Thats going to be a no go, as i need to pass in those variables, but i think i figured it out, I need to beable to nest functions in this, thats why its breaking. Im trying to call a function from a function, that needs to be inside the original function.

How does one nest a function in kixtart? Or, what are the alternatives.


Edited by duo (2008-02-13 06:15 PM)

Top
#185318 - 2008-02-13 06:37 PM Re: Kix+Forms+Active Directory [Re: duo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Nesting??

Functions stand alone, and can be called from any code module or function. EG:
 Code:
Function F1($stuff)

 $Stuff = $Stuff + 'MoreStuff' ; change stuff
 $Stuff = F2($Stuff)           ; modify stuf some more, via F2()

 $F1 = $Stuff
 Exit 0
EndFunction

Function F2($MyStuff)

  If InStr($MyStuff, 'specialstuff')
    ; do special things to $MyStuff..
  Else
   ' do normal things to $MyStuff
  EndIf

  $F2 = $MyStuff
  Exit 0
EndFunction

Thus - the function declarations are independent, but F1() can call F2(). Heck, F1() can even call F1(), known as Recursion, or Recursive Calling. The DirList UDF is an excellent example of recursive calling that comes to mind.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185365 - 2008-02-14 02:43 PM Re: Kix+Forms+Active Directory [Re: Glenn Barnas]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
Thanks for all the info on this, it didnt resolve the issues but did force me to some better standards. That said, I am abandoning this fixforms test, but still need a graphical way to prompt the user for user/pass. People ignore the cmd prompt all day and just let it sit there when it asks them for it.
Top
#185367 - 2008-02-14 02:52 PM Re: Kix+Forms+Active Directory [Re: duo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
One last small question.
Do you run the logon script synchronized? If nor then the users should not be able to go to work before they do something with the command window because windows does not continue to startup before the scripts are done. Forcing users to enter a username and pw in the command window.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#185371 - 2008-02-14 03:42 PM Re: Kix+Forms+Active Directory [Re: Mart]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
I do not.
 Code:
function graphical400($drive,$share,$server)
Dim $choice,$400username,$400password,$passlen,$userlen,$count
$count=0
$userlen=0
$passlen=0
		if exist("$drive")
			? "You already have"+$drive
		else
			$share=$server + $share
			? "mapping $drive to $share"


			$choice = MessageBox("Do you want to map "+$drive+" to "+$share+"?", "AS400 Drives", 36)
			If $choice = 6 ;6=yes to question
				while ($400username=@CRLF|$userlen=0)
					cls
					color y+/n
					? "Please enter your AS400 Username"+@CRLF
					color g+/n
					GETS $400username
					$userlen=len($400username)
				loop

				while ($400password=@CRLF|$passlen=0)
					cls
					color y+/n
					? "Please enter your AS400 Password"+@CRLF
					color g+/n
					GETS $400password
					$passlen=len($400password)
				loop
				
				Use $drive /Delete
				if @ERROR <> "2250"
					error_check(@ERROR,@SERROR,"failed to remove $drive drive")
				endif
				Use $drive $share /user:$400username /password:$400Password
					error_check(@ERROR,@SERROR,"failed to map $drive drive")
				endif
endfunction

Top
#185376 - 2008-02-14 04:30 PM Re: Kix+Forms+Active Directory [Re: duo]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
For anyone interested...
 Code:
;Version 1.2.14.08
;
;
;Function ENUMINI() taken from Kent Dyer,Jens Meyer,Howard Bullock
;and modified for more fields and stopping double entries


BREAK OFF
$ = SetOption('Explicit', 'On')
$ = SetOption('NoMacrosInStrings', 'On')


DIM $osname,$inifile
GLOBAL $vista,$personal_loc,$desktop_loc,$start_loc,$logfilepath



$osname=left(@ProductType,10)
$vista=0

;----------------------------------------------script variables
$logfilepath="S:\logfile.txt"
$inifile="C:\Documents and Settings\duo\Desktop\newlogscript\sample.ini"

if $osname="Windows Vi"
	;Vista Paths
	$vista=1
	$personal_loc="S:\icons\"
	$desktop_loc="C:\Users\"+@USERID+"\Desktop\"
	$start_loc="C:\Users\"+@USERID+"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\"
else
	;XP,2k,2k3 Paths
	$personal_loc="S:\icons\"
	$desktop_loc="C:\documents and settings\"+@USERID+"\desktop\"
	$start_loc="C:\documents and settings\"+@USERID+"\start menu\programs\apps\"
endif
;--------------------------------------------------------














ENUMINI($inifile)	;processes the ini file and takes all specified actions


;testing stuff----stay away!----

;RUN "\\srv05wts\keyfinder\keyfinder.exe /save \\srv05wts\logs$\ /close"

;new thing testing
;if $vista=1
;$filetransfer ='robocopy "%USERPROFILE%\Documents" "S:\My Documents" /MOV /XO';endif
;else
;$filetransfer ='robocopy "%USERPROFILE%\My Documents" "S:\My Documents" /MOV /XO';endif
;endif
;Run $filetransfer
;end test



























FUNCTION ENUMINI($fl)
DIM $sections,$keys,$sectionkey,$sectionentry,$rc,$resource,$commands,$desc,$function,$count
$sections=split(readprofilestring($fl,'',''),chr(10))
	FOR EACH $sectionentry IN $sections
		IF $sectionentry <>''
			$keys=split(readprofilestring($fl,$sectionentry,''),chr(10))
			FOR EACH $sectionkey IN $keys
				IF $sectionkey <>''
					;? 'Key "'+$sectionkey+'" = "'+readprofilestring($fl,$sectionentry,$sectionkey)+'"'
					$resource=readprofilestring($fl,$sectionentry,$sectionkey)
					If InStr($resource, '@USERID')
						$resource = Join(Split($resource, '@USERID'), @USERID)
					EndIF
				IF INGROUP($sectionentry) | @hostname=$sectionentry
					$commands=split('$resource',',')
					$count=0
					For Each $desc IN $commands
					$count=$count+1
						if $count=2; this is nessicary do to the fact that the For Each is running each item twice, essentially a modulus
						;function=$sectionkey desc is=$commands[0] command=$commands[1]
						;? $desc $sectionkey
						run_functions($sectionkey,$commands[0],$commands[1], $commands[2], $commands[3])
						endif
					Next

				ENDIF
				ENDIF
			NEXT
		ENDIF
	NEXT
ENDFUNCTION






function run_functions($function,$desc,$command,$command2,$command3)
$function=left($function,5)


	Select
	case $function="400dr"
		;?"400drive to be mapped is " $desc ":\ from " $command2$command
		graphical400($desc,$command,$command2)
	case $function="drive"
		;? "drive to be mapped is " $desc ":\  from " $server$command
		drive_mapping($desc,$command,$command2)
	case $function="print"
		;? "printer to be mapped is " $desc " from " $printserver$command
		printer_mapping($command2,$command)
	case $function="copyf"
		copy_files($personal_loc,$desktop_loc,$start_loc,$command2,$command)
		? $command
	case $function="regha"
		;? "path is "$desc @CRLF" key is " $command " value " $command2 " type " $command3
		registry_fixes($desc, $command, $command2, $command3)
	case $function="runap"
		;? "command 1 $command @CRLF command 2 $command2"
		Run '$command2$command'
		
	case 1
		error_check(@ERROR,@SERROR,"improper function in run_functions")
	Endselect


endfunction













function copy_files($personal,$desktop,$start,$server,$program)
DIM $file
$file=$server + "icons$\" + $program
	if not exist ("$personal")
		md "S:\icons\"
	endif
	if not exist ("$personal$program")
		;? "need in personal drive"
		COPY "$file" "$personal" /c
		error_check(@ERROR,@SERROR,"couldnt copy $file to $personal")
	endif
	if not exist ("$desktop$program")
		;? "need in desktop"
		COPY "$file" "$desktop" /c
		error_check(@ERROR,@SERROR,"couldnt copy $file to $desktop")
	endif
	if not exist ("$start")
		md "C:\documents and settings\"+@USERID+"\start menu\programs\apps\"
	endif
	if not exist ("$start$program")
		;? "need in startmenu"
		COPY "$file" "$start" /c
		error_check(@ERROR,@SERROR,"couldnt copy $file to $start")

	endif
endfunction









function drive_mapping($drive,$share,$server)
	$share='$server$share'


	? "mapping "+ $drive +" to "+ $share
	Use $drive /Delete
		if @ERROR <> "2250"
		error_check(@ERROR,@SERROR,"failed to remove $drive drive")
		endif

	Use $drive $share
		error_check(@ERROR,@SERROR,"failed to map $drive drive")
		if $drive="S"
			update_logfile()
		endif
endfunction











function printer_mapping($server,$printer)
	If AddPrinterConnection("$server$printer")=0
		? "Added $printer"
	else
		error_check(@ERROR,@SERROR,"couldnt add $printer from $server")
endfunction







function registry_fixes($path,$field,$value,$type)
	WriteValue($path, $field, $value, $type)
	error_check(@ERROR,@SERROR,"Couldnt modify $field")

endfunction















function error_check($errnum,$error,$message)
	If @ERROR<>0
		Open(1,$logfilepath, 5)
		WriteLine(1, @DATE + " " + @TIME + " Error# $errnum $error occured, $message" + Chr(13) + Chr(10))
		Close(1)
	EndIf
endfunction











function update_logfile()
		Open(1,$logfilepath, 5)
		WriteLine(1, @CRLF + @DATE + " " + @TIME + " LogonServer=" + @LDRIVE + " Computer=" + @HOSTNAME + Chr(13) + Chr(10))
		Close(1)
endfunction





function graphical400($drive,$share,$server)
Dim $choice,$400username,$400password,$passlen,$userlen,$count
$count=0
$userlen=0
$passlen=0
		if exist("$drive")
			? "You already have"+$drive
		else
			$share=$server + $share
			? "mapping $drive to $share"


			$choice = MessageBox("Do you want to map "+$drive+" to "+$share+"?", "AS400 Drives", 36)
			If $choice = 6 ;6=yes to question
				while ($400username=@CRLF|$userlen=0)
					cls
					color y+/n
					? "Please enter your AS400 Username"+@CRLF
					color g+/n
					GETS $400username
					$userlen=len($400username)
				loop

				while ($400password=@CRLF|$passlen=0)
					cls
					color y+/n
					? "Please enter your AS400 Password"+@CRLF
					color g+/n
					GETS $400password
					$passlen=len($400password)
				loop
				
				Use $drive /Delete
				if @ERROR <> "2250"
					error_check(@ERROR,@SERROR,"failed to remove $drive drive")
				endif
				Use $drive $share /user:$400username /password:$400Password
					error_check(@ERROR,@SERROR,"failed to map $drive drive")
				endif
endfunction

Top
#185413 - 2008-02-17 12:34 PM Re: Kix+Forms+Active Directory [Re: duo]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
didn't try on vista yet but wouln't %userprofile% and %appdata% provide the corrent paths in all OS's ?
Top
#185418 - 2008-02-17 07:25 PM Re: Kix+Forms+Active Directory [Re: Arend_]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
True
Or look for it in the registry under the key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
See FAQ: Locations of Desktop, Start Menu, etc.

Top
#185419 - 2008-02-17 10:20 PM Re: Kix+Forms+Active Directory [Re: Witto]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
HKLM or HKCU?

One should NEVER hard code @UserID in a path! It's so noobish. tsk tsk
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#185420 - 2008-02-18 12:27 AM Re: Kix+Forms+Active Directory [Re: Les]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Right Les
I wanted to point to the HKEY_CURRENT_USER part of the registry

Top
#185435 - 2008-02-18 04:25 PM Re: Kix+Forms+Active Directory [Re: Les]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
 Originally Posted By: Les

One should NEVER hard code @UserID in a path! It's so noobish. tsk tsk

I am open to suggestions

Top
#185436 - 2008-02-18 04:28 PM Re: Kix+Forms+Active Directory [Re: duo]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I think Les means to say that one should never hardcode the username (eg. jsmith) but use the @userid macro so if a users gets renamed stuff will still work. This way it will work for all users it applies so you don’t have to create separate scripts or lines for each user.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 2 of 3 <123>


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

Who's Online
0 registered and 833 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.076 seconds in which 0.027 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