Page 1 of 1 1
Topic Options
#195716 - 2009-09-02 01:08 AM KiXtart reads database
DarkMasterHalo Offline
Just in Town

Registered: 2009-09-02
Posts: 2
Loc: Canada
Hi people,

I've been dealing with Kix for about 2-3 years now and I find it great for Windows Logon script. The way we are doing it now, we have a common login script for everybody than a personal one that maps the necessary drives, printers, etc.

In order to simplify and reduce the amount of files we are using, I would like to input the personal drive location for users in a database therefore resulting in only one file to maintain.

So here is my idea: In my common login script I would check in a SQlite database for these personal preferences. However, I've looked for informations on that subject and it was all unclear. I've come accross the function DBConnConnect() which is able to connect Access database and such but nothing with SQlite, at least, not from what I know.

If somebody would be kind enough to paste a codesnippet or just a link :), I've been searching for this forever. I'm also willing to learn alternative ways of doing it, it was just an idea I had a day I wanted to optimize my login script \:\)

Thanks folks for your answers.

Top
#195718 - 2009-09-02 02:36 AM Re: KiXtart reads database [Re: DarkMasterHalo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Welcome to KORG!

Our login script can do what you're looking for with a single INI file. We use something called Value Rewrite to change some or all of the UNC path that the resource maps to. There are 9 ways to handle the rewrites - User, User:Lookup, OU, OU Lookup, ComputerOU, ComputerOU Lookup, AD Site, AD Site Lookup, and Subnet lookup. Four of these simply replace a macro in the UNC path with the UserID, OU, Computer OU, or AD Site values, while the others actually look up a replacement value in a table. This allows us to, for example, have one definition to map the S: drive with 430 unique paths, for department-specific share paths, one per departmental OU.

Since we started offering commercial support, we no longer distribute source code to the login script, but you might get some ideas from the user guide on our web site. Of course, you could try the script itself, too.

Based on my experience, a central database or config file might work well in a LAN environment, but would likely suffer considerable performance degradation over a WAN connection. At one client with many remote retail locations, the login script they used took as much as 80 seconds to complete using an Access back-end on the WAN. Implementing our script brought the LAN time down to 3-4 seconds, and the WAN times to around 12 seconds (256K F/R connections). This is based on 30 disk resource checks, 7-9 being mapped, 2 printer connections, 1-2 message files displayed, and 2 external commands run (set the background w/ BGInfo, and verify/update a desktop icon which links to the intranet.

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

Top
#195721 - 2009-09-02 03:47 AM Re: KiXtart reads database [Re: Glenn Barnas]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The DB...() series of UDFs, like DBConnOpen(), should be able to handle any database for which the proper drivers are installed.

See http://www.connectionstrings.com for proper syntax.
_________________________
There are two types of vessels, submarines and targets.

Top
#195728 - 2009-09-02 12:34 PM Re: KiXtart reads database [Re: Sealeopard]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I would think a simple INI file would be simpler to maintain and faster to implement and operate.
Top
#195729 - 2009-09-02 01:42 PM Re: KiXtart reads database [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The other issue I can think of is that a DB - specifically a SQL server of some kind - presents a single point of failure. The INI file is replicated to all DCs, maintaining performmance and reliability. This was the reason that Access was used at the client site that I referenced above.

Jens put a lot of effort into his DB UDFs, and in any other situation I'd be pushing you in that direction. They are stable and reliable, but I personally don't think that using a DB is appropriate for a login script application.

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

Top
#195732 - 2009-09-02 04:44 PM Re: KiXtart reads database [Re: Glenn Barnas]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Write to db
 Code:
		$cn = CreateObject("ADODB.Connection")	$cmd= CreateObject("ADODB.Command")	$rs = CreateObject("ADODB.RecordSet")
		$cn.connectionstring = "DRIVER={SQL Server};SERVER=sqlserver;UID=username;PWD=password;DATABASE=dbname"
		$cn.open
			$cmd.activeconnection = $cn
			$rs.cursortype = 3
			$rs.locktype = 3
			$rs.activecommand = $cmd
			$cmdtxt = "select * from dbo._tbl_Main where SerialNumber = '$serNo'"
			$cmd.commandtext = $cmdtxt
			$rs.open ($cmd)				;? 'Error = '+@ERROR+' - '+@SERROR
				IF $rs.eof = -1		$rs.addnew	ENDIF 
				$rs.fields.item("UserName").value      = @userid
				$rs.update			;? 'Error = '+@ERROR+' - '+@SERROR
			$rs.close
		$cn.close
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#195733 - 2009-09-02 04:50 PM Re: KiXtart reads database [Re: Radimus]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
read from db
 Code:
	$cnstring = "DRIVER={SQL Server};SERVER=sqlserver;UID=username;PWD=password;DATABASE=dbname"

	$cn = CreateObject("ADODB.Connection")
	$cmd= CreateObject("ADODB.Command")
	$rs = CreateObject("ADODB.RecordSet")

	$cn.connectionstring = $cnstring
	$cn.open
	$cmd.activeconnection = $cn
	$rs.cursortype = 3
	$rs.locktype = 3
	$rs.activecommand = $cmd

	$cmdtxt = "select * from dbo._tbl_Main where SerialNumber = '$serNo'"
		$cmd.commandtext = $cmdtxt 
		$rs.open ($cmd)			;? 'Error = '+@ERROR+' - '+@SERROR
			$serNo 	  = $rs.fields.item("SerialNumber").value
			$wksta    = $rs.fields.item("ComputerName").value 
			$assigned = $rs.fields.item("AssignedTo").value 
			$network  = $rs.fields.item("NetworkID").value 
			$ip 	  = $rs.fields.item("IPAddress").value 
			$date 	  = $rs.fields.item("InvDate").value 
		$rs.close
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#195734 - 2009-09-02 04:52 PM Re: KiXtart reads database [Re: Radimus]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
all that aside.. the ini file is still the best method for this goal
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#195735 - 2009-09-02 05:07 PM Re: KiXtart reads database [Re: Radimus]
DarkMasterHalo Offline
Just in Town

Registered: 2009-09-02
Posts: 2
Loc: Canada
Hi,

Okay, thank you all for this precious information. I'll develop my script on the database side for the moment since we're only providing loggin ressource inside our LAN. Maybe I'll develop one with an INI file as suggested. I'll post my code here for further reference and help :).

Have a nice day all (well or night...)

PS.: Thank you Radimus for the piece of code \:\)
PPS.: Very useful and friendly forum too.

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.06 seconds in which 0.026 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