macoxy
13th December 2002, 14:18
I made a skript to prevent more than one session per user,
but now i have problem, we have 100 baan licences, but i want to use only 90 licences for normal users, and reserve 10 license for administrators.
How can i send message to user that there are no more licenses free, i can't do this with bshcmd6.1 because i don't got his bshell PID
gentercz
13th December 2002, 14:52
i suggest you start a short shell script like "ps -ef|grep bshell" to get all the shell pid's from baan: shell("...", 0).
put the output in a file and read it in baan
then you can use the bshcmd6.1
hope this helps,
jochen
macoxy
13th December 2002, 15:53
i will explain one more time
when user try's to log in and all licences are being used, i only want to give them 90 of 100 licences for use, he can't run a bshell anymore, so i can not get his bshell id and i cant send him a message. usually licencedeamon sends a message that there are no more licences free.
and one more question i have next line in my skript
---------here i get users PID-----------
USER_PID=`ps -ef | grep bshell6.1 | grep -i ${USER} | grep -"grep bshell6.1" | cut -c 10-14`
--------------here i'am sending him a message----------------
bshcmd6.1 -w1 -u1 -M "you can only login once !!" ${USER_PID}
sleep 5
this happens when user tries to login 2times.
it's all working ok, message is beeind send to users display, but
an error acures too
(boot failed of user 'xy' remote user 'xy' server 'xy!bshell' 'bse' '/baan/bse' boot '/baan/bse/bin/ipc_boot6.1')
thank's
victor_cleto
13th December 2002, 20:15
Good question...
Since you never start a bshell, what happens is that there is no feedback sent to the user.
What about starting a bshell in the background (&) for the user, get it's PID, issue a bshcmd6.1 to it's PID with a message that also mentions that his connection will be terminated in 5 seconds, include a sleep and then "kill" it.
This should do the trick (not tested though).
macoxy
16th December 2002, 09:09
if i run bshell6.1 vith &, i got out a message "connection with server lost" dam i'am out of idea, i don't know what to do more
p.cole
16th December 2002, 21:07
How about doing a "net send <login> There are no more licenses".... this could be possible if you use samba on unix and bw clients
gentercz
17th December 2002, 10:27
i would suggest you create a new session that is auto-started with every baan login.
in this session you check the licences and if a licence is duplicate or number of licences have expired, then you give a baan message and kill the current bshell ....
we have done this and it works pretty good ...
jochen
chjagge
27th December 2002, 21:13
I used a combination of C, ci_server, new baan sessions and new baan tables. Everytime a user logs in they increment a counter in some tables in Baan. Then I return a value which is translated to a message that is returned to the user. This is in production right now.
Anyone wanting the script please post and I'll email it to you.
tjbyfield
29th December 2002, 03:08
Hi Chjagge
I am very interested in you solution. Would it be possible to either post or email a copy of you C code ? A listing of you new tables would also be great.
(my email is tbyfield@kembla.com.au)
Thanks
Terry
chjagge
30th December 2002, 20:49
I had the C program pasted in here but took it down. If you wish to see the C program I can email it to you.
chjagge
30th December 2002, 20:57
See attachment for file tabledef.txt
tjbyfield
31st December 2002, 04:30
Chjagge
Thank you for you c code.
I am interested in the c interface (and I have been disappointed that no one has replied to your ealier post.)
In you c code you refer to a Baan dll 'login_dll' , is this a dll that you made or is it a supplied dll ?
Terry
chjagge
31st December 2002, 13:59
Unfortunately the indentation are removed when posting.
|******************************************************************************
|* tctkndll0002 0 VRC B40O c2 bta0
|* Evaluate Login
|* bsp
|* 06-07-02 [08:02]
|******************************************************************************
|* Script Type: Library
|******************************************************************************
|******************************************************************************
|* tctkn9201 0 VRC B40O c2 bta0
|* Update User logon reference counter
|* Chjagge
|* 2002-03-08
|******************************************************************************
|* Main table tctkn021 User logon reference counter, Form Type 4
|******************************************************************************
|****************************** declaration section ***************************
table ttctkn021 | User logon reference counter
table ttctkn022 | Cost Center Max Users
table ttctkn023 | License Usage Limit by Company
table ttctkn024 | Parent Company - SubCompany Link
table tttaad200 | User Data
domain tcmcs.str12 user.f fixed
domain tcmcs.str12 user.t fixed
domain tcmcs.long maxusers.w
domain tfgld.dimx costcenter.w
domain tcmcs.long comp.users
domain tfgld.dimx parent.comp
string buf.tctkn021(1) based
#include "/baan/bse/application/tcB40O_c2_bta0/ptctkn/ptkndll00010" | Encryption
function extern long baan_logout(string user.w(12))
{
long count
long ret
ret = 1
| user.f = strip$(logname$)
| user.t = strip$(logname$)
set.mem(user.f, " ", 12)
set.mem(user.t, " ", 12)
user.f = strip$(user.w)
user.t = strip$(user.w)
db.retry.point()
select tctkn021.*
from tctkn021 for update
where tctkn021._compnr = 100
and tctkn021._index1 inrange {:user.f}
and {:user.t}
order by tctkn021._index1
selectdo
| update set
if tctkn021.logc > 0 then
tctkn021.logc = tctkn021.logc - 1
db.update(ttctkn021, db.retry)
endif
count = count + 1
if count > 50 then
count = 0
commit.transaction()
endif
selectempty
ret = 7
| message("User Missing from Logon - Cost Center file")
endselect
commit.transaction()
return(ret)
}
function extern long check_login(long flogin, string user.w(12))
{
long count
| user.f = strip$(logname$)
| user.t = strip$(logname$)
set.mem(user.f, " ", 12)
set.mem(user.t, " ", 12)
user.f = strip$(user.w)
user.t = strip$(user.w)
long ret
ret = 1 | true and allow login if ret is 1
db.retry.point()
|*** Re align login count with that in UNIX
if flogin <> 999 then
select tctkn021.*
from tctkn021 for update
where tctkn021._compnr = 100
and tctkn021._index1 inrange {:user.f}
and {:user.t}
order by tctkn021._index1
selectdo
tctkn021.logc = flogin
db.update(ttctkn021, db.retry)
selectempty
endselect
endif
|*** Above select re-align login counts with that on UNIX
select tctkn021.*
from tctkn021 for update
where tctkn021._compnr = 100
and tctkn021._index1 inrange {:user.f}
and {:user.t}
order by tctkn021._index1
selectdo
| update set
if (tctkn021.conu > tctkn021.logc) then
costcenter.w = tctkn021.dimx
sum.users.for.cost.center()
select tctkn022.*
from tctkn022
where tctkn022._compnr = 100
and tctkn022._index1 = {:costcenter.w}
selectdo
if tctkn022.maxu > maxusers.w then
sum.users.for.company()
if under.company.max() then
ret = 1 | Used only for emphasis since already initialized above
tctkn021.logc = tctkn021.logc + 1
db.update(ttctkn021, db.retry)
else
| message("Login at this time is not possible. Max users for company has been reached")
ret = 6
endif
else
ret = 2
| message("Login at this time is not possible. Max users for your department has been reached")
endif
selectempty
ret = 3
| message("Missing Cost Center")
endselect
count = count + 1
if count > 50 then
count = 0
commit.transaction()
endif
else
ret = 4
| message ("Number of licenses assigned to you exceeded. Limit - " & str$(tctkn021.conu) & " licenses")
endif
selectempty
ret = 5
| message("User Missing from Logon - Cost Center file")
endselect
commit.transaction()
return (ret)
}
function sum.users.for.cost.center()
{
select sum(tctkn021.logc):maxusers.w
from tctkn021
where tctkn021._compnr = 100
and tctkn021._index2 = {:costcenter.w}
selectdo
endselect
}
function sum.users.for.company()
{
domain tcncmp save.comp
domain tcncmp user.comp
long len.tctkn021
db.row.length(ttctkn021, len.tctkn021)
alloc.mem(buf.tctkn021, len.tctkn021)
buf.tctkn021 = rcd.ttctkn021
comp.users = 0
save.comp = get.compnr()
select tctkn024.*
from tctkn024
where tctkn024._compnr = 100
and tctkn024._index1 = {:save.comp}
selectdo
parent.comp = tctkn024.pcmp
selectempty
parent.comp = ""
endselect
select tctkn021.*
from tctkn021
where tctkn021._compnr = 100
order by tctkn021._index1
selectdo
select ttaad200.*
from ttaad200
where ttaad200._compnr = 0
and ttaad200._index1 = {:tctkn021.user}
selectdo
user.comp = ttaad200.comp
select tctkn024.*
from tctkn024
where tctkn024._compnr = 100
and tctkn024._index2 = {:parent.comp, :user.comp}
order by tctkn024._index2
selectdo
comp.users = comp.users + tctkn021.logc
endselect
endselect
endselect
rcd.ttctkn021 = buf.tctkn021
free.mem(buf.tctkn021)
}
function domain tcbool under.company.max()
{
select tctkn023.*
from tctkn023
where tctkn023._compnr = 100
and tctkn023._index1 = {:parent.comp}
order by tctkn023._index1
selectdo
if tctkn.dll0001.decrypt(tctkn023.musr, tctkn023.pcmp) >
comp.users then
return(true)
endif
endselect
return(false)
}
chjagge
31st December 2002, 15:47
About a year ago I asked if anyone played with the
ci_server but I got no response. I played with the ci_server and together with the example in
/baan/bse/api/examples/cint. I got it to work for me. This opens up a whole new portal into Baan. Some guys do IP & Socket programming but why bother when the ci_interface does it for you.
You will need to use the makefile in there, modifying it for your own C and dll's.
tjbyfield
1st January 2003, 05:05
Chjagge
Thank you for the baan dll code. Now it looks easy. I will give it a try
Terry:)
chjagge
1st January 2003, 08:08
Let me know if I can be of further help
eibrahimovic
16th October 2003, 13:35
Hi,
We are develop some application on VBNet whitch writing user logon in access table. Number of user login is restricted by departmet. When number of users in department riched number which admidminitrator allows hi get message that his department is riched max number of licens. On client part of software when run them hi see all user from his depatrment, max number of licens and so on.
You can develp same or if you intrested I can send to you Demo.
Troy2004
8th July 2004, 07:28
Hi,
I am trying to use victor_cleto method. I am on Baan4 on Windows NT.
I have created a session to run at startup and this session counts the number of bshell currently connected. I want to be able to delete this current bshell after a check on the maximum.
How do I get the current bshell id that I am using?
licmon > usertxt gives you a list
but I want to know which one i am running on now so that i can kill it.
Hope you understand my requirement
Thanks and regards
pemcgriff
1st July 2006, 14:59
Is there a way to capture the message that the license demon sends to a user when there are no more licenses available? Because this happens infrequently I am interested in finding out how often it is occuring and when (i.e. beginning of month during finance closing).
Thanks