#195716 - 2009-09-02 01:08 AM
KiXtart reads database
|
DarkMasterHalo
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
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!
|
|
Top
|
|
|
|
#195732 - 2009-09-02 04:44 PM
Re: KiXtart reads database
[Re: Glenn Barnas]
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Write to db
$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
|
|
Top
|
|
|
|
#195733 - 2009-09-02 04:50 PM
Re: KiXtart reads database
[Re: Radimus]
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
read from db
$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
|
|
Top
|
|
|
|
#195734 - 2009-09-02 04:52 PM
Re: KiXtart reads database
[Re: Radimus]
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
all that aside.. the ini file is still the best method for this goal
|
|
Top
|
|
|
|
#195735 - 2009-09-02 05:07 PM
Re: KiXtart reads database
[Re: Radimus]
|
DarkMasterHalo
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|