Page 1 of 1 1
Topic Options
#48944 - 2000-02-03 01:30 PM Prevent users from logging on more than once
Anonymous
Unregistered


Dear All
We need to develop the following script in kixtart, any on can help Please..To prevent users from logging on more than once.
$K = "@LSERVER" + "\" + "NETLOGON" + "\" + "Once.txt"
$J = "x:\" + "@USERID" + ".txt"
if exist ("$J")
goto done
endif
CLS
AT (1,1)
display "$K"
Sleep 3
$RC = shutdown("", "Shutdown in progress!", 0, 1, 0)
:done

Top
#48945 - 2000-02-03 05:22 PM Re: Prevent users from logging on more than once
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Wouldn't this be cleaner if you created each user share with oneuser.txt in it and set the security permissions for that file for one user only. Then attach & open file on logon if you can't attach it then it is already being used - then force a log off.

For you method to work it seems to me you must delete userid.txt at the end of each session. Can you guarantee this? Doesn't this clutter up your netlogon share?

_________________________
Jack

Top
#48946 - 2000-02-03 05:32 PM Re: Prevent users from logging on more than once
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Sorry, long day. That seems to be what you are trying to do. We don't do this anymore but we use to do it in a batch script we lifted from here:
http://www.jsiinc.com/reghack.htm

Also this has been discussed in a previous post. I tried to search for it but the search engine only gives 2000 results. I believe that it was posted in late 1999.

_________________________
Jack

Top
#48947 - 2000-02-07 06:22 AM Re: Prevent users from logging on more than once
Anonymous
Unregistered


Dear JackLothian
I still got the information post last year, it is not working, if you got example can you e-mail to me Please
THamid@candi.ac.uk
Thanks

Top
#48948 - 2000-02-09 10:41 AM Re: Prevent users from logging on more than once
Anonymous
Unregistered


All,

My idea is the following:

Log the Workstation name of the computer the users logs on to into a textfile on the users homeshare with WRITEPROFILESTRING.

WRITEPROFILESTRING ("Filename", "Network", "LoggedOnTo", @WKSTA)

During logon, read that value with READPROFILESTRING

$LoggedOnTo = READPROFILESTRING ("file name", "Network", "LoggedOnTo")

Do an "NBTSTAT -a $LoggedOnTo" and check the output for the users username.
If that username is inthere, the user is still logged on to that workstation, so do NOT update the file on the usershare and force a logoff.
If the username is NOT found in the output of that NBTSTAT, update the textfile on the usershare and continue logon.

This way, a user can also normally logon if he/she was logged off abnormally.

PLease give me feedback about this!

Regards,

Marc

------------------
M.A.C. Duiker (Marc)
Migration Specialist (MCSE)
Marc.AC.Duiker@ici.com
[img]https://partnering.one.microsoft.com/SecureImages/mcp_c.gif[/img]


Top
#48949 - 2000-02-10 10:29 AM Re: Prevent users from logging on more than once
Anonymous
Unregistered


Hi Marc
I thing it is very good idea I will try it and come back to you
Thanks

Top
#48950 - 2000-02-14 09:38 AM Re: Prevent users from logging on more than once
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I think most of the info you need is on the NT Reghack site. Tip 175 gives a general solution that I believe works for both Win95 & NT clients and it uses a kixtart based solution.

175 » Prevent users from logging on more than once. http://www.jsiinc.com/TIP0100/rh0175.htm

For further info see Tip 120 which is an introduction to writing a kixtart logon script.

120 » Solve those logon script problems. http://www.jsiinc.com/TIP0100/rh0120.htm

Here is an alternative solution that uses a freeware utility. I believe that this solution is NT specific. You would have to shellout to execute this script. This might be an alternative to the NT solution that is offered above.

0296 » A better way to prevent a user from logging on more than once. http://www.jsiinc.com/TIP0200/rh0296.htm

This a freeware utility to help with logging off any user who trys to logon twice.

184 » Logout is Freeware and works on WinNT and W95. http://www.jsiinc.com/TIP0100/rh0184.htm

_________________________
Jack

Top
#48951 - 2001-02-19 10:16 PM Re: Prevent users from logging on more than once
Anonymous
Unregistered


It's a old topic, still a year, but still useable for some people.
A question to MDuiker, how can I check the output for the users username with the command "NBTSTAT -a $LoggedOnTo" ?
I understand you suggestion and I think it must work.

------------------
http://www.sanderwinkel.com

Top
#48952 - 2001-02-20 08:53 PM Re: Prevent users from logging on more than once
Anonymous
Unregistered


Of course other people may reply to my question too.

------------------
http://www.sanderwinkel.com

Top
#48953 - 2001-02-21 02:21 AM Re: Prevent users from logging on more than once
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
Awinkel -
NBTSTAT will return ip address, session info and MAC address. MDuiker is using the variable $LoggedOnTo for the users workstation. So, executing NBTSTAT -a <workstation id> will return the NetBIOS remote machine name table. Entry <03> in the display should be the user logged onto to the workstation. If no 'O3' entry no one logged into (likely only missing with NT/2K, but I have not tested).

The trick will be pulling the info for entry '03' from your output file and using it. CJ or Bryce - any good ideas?

Bill

Top
#48954 - 2001-02-21 09:15 AM Re: Prevent users from logging on more than once
Anonymous
Unregistered


The command "nbtstat -a $LoggedOnTo" returns two 03 entries.
The last one gives the username.
So you must searching for a 03 entry that contains the username and not a another 03 entry who gives the workstation name.
But how to do that?

------------------
http://www.sanderwinkel.com

Top
#48955 - 2001-02-27 04:25 PM Re: Prevent users from logging on more than once
Anonymous
Unregistered


It works!
For who cares this is the script:

$message="Er is al iemand met deze loginnaam op het netwerk ingelogd, je wordt nu uitgelogd." +chr(13)+ "Vraag je docent naar je goede loginnaam of laat je docent contact opnemen met systeembeheer."

$LoggedOnTo=READPROFILESTRING ("h:\once.txt", "Garfield", "LoggedOnTo")
If @error <> 0 goto "write" Endif
If $LoggedOnTo = @wksta goto "end" Endif

? "Bezig met zoeken op netwerk..."
shell "%comspec% /c NBTSTAT -a $LoggedOnTo > h:\nbt.txt"
? "Klaar"

If Open(1, "h:\nbt.txt") = 0
$x = ReadLine(1)
WHILE @ERROR = 0
If instr($x, @userid)
messagebox($message,"Hoi @userid",016)
SHELL "rundll32.exe shell32.dll,SHExitWindowsEx 5"
Endif ; from instr
$x = ReadLine(1)
LOOP
Close(1)
ELSE
? "Bestand H:\NBT.TXT niet gevonden, waarschuw de netwerkbeheerder: Errorcode " + @ERROR ;+ ""
ENDIF

:write
WRITEPROFILESTRING ("h:\once.txt", "Garfield", "LoggedOnTo", @WKSTA)

:end

------------------
http://www.sanderwinkel.com

Top
#48956 - 2001-03-26 04:36 PM Re: Prevent users from logging on more than once
Anonymous
Unregistered


We decided to go with a little program called "ntname.exe". It returns the logged in workstation for any given username. If the username is not logged in you get back nothing. Easy enough! Only problem is people who are smart enough to unplug their network cable wile logging in on a second PC, but I don't see that solved by this script...

code:

IF INGROUP("MULTIPLE") GOTO NANTNAME ENDIF
SHELL '%comspec% /c @LDRIVE\tools\ntname\ntname.exe @userid > c:\ntname.txt'
$null = OPEN (4,c:\ntname.txt)
$result=READLINE(4)
$null = CLOSE(4)
DEL "c:\ntname.txt"
IF $result
$error="Multiple logons not allowed, according to our information you are already logged on to $result"
$tijd=""
$actie="U wordt nu automatisch uitgelogd"
CALL (@LDRIVE + "\errorscript.kix")
ENDIF
:NANTNAME


Top
#48957 - 2001-04-10 06:41 PM Re: Prevent users from logging on more than once
Anonymous
Unregistered


I don't think ntname.exe doesn't work on w9x cliėnts,isn't it?

------------------
http://www.sanderwinkel.com

Top
#48958 - 2001-05-31 12:21 AM Re: Prevent users from logging on more than once
vvo Offline
Fresh Scripter

Registered: 1999-07-16
Posts: 6
Loc: Arnhem, Gld, Netherlands
Hi,
Trying to implement the script of Sander Winkel. However I have troubles using the following command:

shell "%comspec% /c NBTSTAT -a $LoggedOnTo > h:\nbt.txt"

It refuses to use the var $LoggedOnTo ... my output of nbtstat is always 'host not found'.

To my findings I don't have a special setup .. I'm using:

NT4 with SP6a as clients
NT4 PDC logon server

Johan. www.htsautotechniek.nl

_________________________
Johan Vorsterman van Oijen (Netherlands)

Top
#48959 - 2002-07-17 03:29 AM Re: Prevent users from logging on more than once
Anonymous
Unregistered


Hey Everyone,

The forums have been an excellent resource & I can't lurk anymore. I just read what Kdyer posted here and I realized that I should share my most recent bit of KiXtart script.

Using what I read in this thread, (including the other threads linked herein) & some I searched for, and from the info JSIinc, after some work, it works really well.

FYI We're a Public School District, Win2k shop (Active Directory, Exchange 2k, Win2k Pro on the desktops, a few 9x & XP Pro boxes, but not for the students--all W2K pro). We were asked to limit concurrent logons for high school students, after the principal learned students who weren't supposed to be logging on, were. Of course, the easiest & most cost-effective way to do this without buying 3rd party software, was with KiXtart (Mike Myers in the background "Kix, yeah baby!")

Now that I've put you to sleep with the background, here's the script. Thanks to everyone who posts. You guys are lifesavers. If you have any feedback, please leave it. [Smile]
Apologies if the code is too wide, I tried to shorten it....
code:
:BlockConcurrent
;
;block concurrent logons
;

If (InGroup("2002group") or InGroup("2003group"))
gosub ConcurrentLogoff
else
If (InGroup("2004group") or InGroup("2005group"))
gosub ConcurrentLogoff
else
? "you are not a HHS student"
endif
endif
RETURN

;Rem ConcurrentLogoff is not called by main, rather from the BlockConcurrent subroutine
:ConcurrentLogoff
shell @ldrive + "\gotcha.bat" ;run ntname and capture the output to a text file in
;the user's %temp% dir
If open( 3, "%temp%\otherpc.txt" ) = 0
$y = ReadLine(3)
If $y = "" ;they're ok
? "It appears that this is the only PC you're currently logged on to."
else
$logoff = 1 ;log 'em off!
? "It appears as though you are already logged on to $y"
? "bummer!"
gosub ForceLogoffLog
messagebox ("You appear to be logged on to '$y'. You are not authorized
to log on to more than one workstation at a time. You must first log off
'$y'.", "Warning! Concurrent Logons Prohibited", 16, 7)
gosub ForceLogoff
LogOff(1)
EndIf
Close (3)
else
If Open( 2 ,"\\server\LogonLogs$\" + "ErrorLog.TXT", 5 ) = 0
$x = WriteLine( 2 ,@userid + ", " + @FullName + ", " + @Comment + ", could not
open otherpc.txt locally from " + @Wksta + ", " + "at " + @time + " " +
@date + ", " + $IPAddress + ", " + @address + ", " + @LServer
+ ", " + $ConnectionType + ", " + $Ver + Chr(13) + Chr(10) )
$l = Close(1)
endif
EndIf
RETURN


:ForceLogoffLog
If Open( 1 ,"\\server\LogonLogs$\" + @year + "_" + @MonthNo + "_DuplicateLogon" +
".TXT", 5 ) = 0
$x = WriteLine( 1 ,@userid + ", " + @FullName + ", " + @Comment + ", tried to log
on to " + @Wksta + ", but was already on " + $y + " at " + @time + " " +
@date + ", " + $IPAddress + ", " + @address + ", " + @LServer + ", " +
$ConnectionType + ", " + $Ver + Chr(13) + Chr(10) ) $l = Close(1)
Endif
RETURN

Incase anyone wants to know what "Gotcha.bat" looks like, it's just
code:
@echo off
%0\..\NTNAME.EXE %USERNAME% >%TEMP%\OTHERPC.TXT
exit

The only routine called is "BlockConcurrent".
"ntname.exe" works fine, one oddity, the script doesn't seem to work on Windows XP Professional (which we have in limited trials around our district. Since students never use any of these, it's fine. It may become an issue in the future). Other than that, no worries.

Thanks again!

[ 17 July 2002, 03:32: Message edited by: martums ]

Top
Page 1 of 1 1


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

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.063 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

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