#20461 - 2002-04-23 04:40 PM
group variable
|
scsigrrrl99
Fresh Scripter
Registered: 2002-04-22
Posts: 13
Loc: florida
|
nailed the home directory issue, now trying to figure out how to use a group variable (if that is even the right term to use! I am not sure).
here is what I have so far (and it works...and the @homeshr does NOT work for some reason, on Win98 anyway):
$s1="\\server1\" $hdrive=$s1+@userid use H: $hdrive
now I want to add something like:
$g="\\server\dir2" $gdrive=$g+@groupvariable use G: $gdrive
where "\\server\dir2" is the shared parent directory, called Groups, and under this shared Groups directory are several different directories, each shared for a different global group of users. So if UserA is in the PER group, then somehow (maybe some macro like @comment?) would know that the group for UserA here was PER, and then G: would map to \\server\Groups\PER.
or perhaps @Primarygroup would work?
Thanks, scsigrrrl99
|
|
Top
|
|
|
|
#20462 - 2002-04-23 05:10 PM
Re: group variable
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
How are you assigning groups? I assume you are going to assign them by either NT groups, by passing a variable from the calling .bat file, or by user lists.
You can use the INGROUP function to see if the user is in a certain NT group and assign them drives based on that. Are there any drive mappings assigned to everyone?
If you could post a sample list of users, what groups they're in, and what drive mappings each group needs to get, then it may be easier to show you ways it can be scripted.
Brian
|
|
Top
|
|
|
|
#20463 - 2002-04-23 06:16 PM
Re: group variable
|
scsigrrrl99
Fresh Scripter
Registered: 2002-04-22
Posts: 13
Loc: florida
|
every user should get an H: drive and a G: drive. The H: drive is supposed to map to their home directory. The G: drive is supposed to map to their group directory.
User1 is in the PER group. User2 is in the ACD group.
These are functional, organizational groups. The PER group works together and shares documents with each other. Anybody NOT in the PER section of the organization has no business using the PER shared group directory. The same goes for the ACD group. Anybody who was hired to work in the ACD section of the organization can put shared documents on the ACD shared directory for other people in the ACD section to read/use, etc. If you are not in the ACD section, then you don't need to see docs on the ACD shared directory.
So, my goal is to have everyone who is in the PER group get a G: drive mapping to \\server1\PER share and everyone in the ACD group to get a G: drive mapping to the \\server1\ACD share.
All of the shared group directories are under a directory called "Groups" which has also been shared on Server1. All of the user accounts have a primary group set (in User Manager) to the same name as the group shared directory, so if you are in the ACD group, and you are supposed to have a G: drive that points to the ACD share on Server1, then your primary group is set to ACD in User Manager, and the ACD group has permission to access the ACD directory on Server1.
I tried the following but it didn't work:
$g="\\Server1\Groups\" $gdrive=$g+chr(36)+@primarygroup use G: $gdrive
(the Groups directory on Server1 is a hidden share)
I may be having a problem with the RPC service, since most of my clients are Win98 and that @primarygroup macro is dependent on the RPC service in order to work on Win9x machines.
However, I just tried the following, and it isn't working for me either:
If INGROUP("PER") Use G: "\\Server1\PER" END IF
it actually complained about the END IF part, so I took that out, but it still won't map, or even connect to the \\Server1\PER share.
Thanks for any help on this, SCSIGRRRL99
|
|
Top
|
|
|
|
#20464 - 2002-04-23 06:33 PM
Re: group variable
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Hmm. first off.. it's ENDIF not END IF .. that could be part of the problem?
Otherwise, it could be something like:
code:
IF "@HOMESHR" <> "" USE H: @HOMESHR ENDIF
IF INGROUP("PER") <> 0 USE G: "\\server\PER$$" ENDIF
IF INGROUP("ACD") <> 0 USE G: "\\server\ACD$$" ENDIF
This assumes that you are using the \\server\groups\ACD folder and sharing it as ACD$. Also, that you are using the \\server\groups\PER folder and sharing it as PER$.
If this isn't quite right, then I'll need more info to understand what you're doing.
Brian
|
|
Top
|
|
|
|
#20466 - 2002-04-23 06:55 PM
Re: group variable
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Yeah, thanks, Jens.. I thought about that AFTER I posted..
Brian
|
|
Top
|
|
|
|
#20468 - 2002-04-23 07:21 PM
Re: group variable
|
scsigrrrl99
Fresh Scripter
Registered: 2002-04-22
Posts: 13
Loc: florida
|
what about the @primarygroup macro? anybody know of a script that uses that? for drive mappings perhaps?
Also, some questions about the code you posted:
these shares are not hidden shares...so, do I really need the $$ at the end? couldn't I just use the following instead:
IF '@HOMESHR'<>'' USE H: @HOMESHR ENDIF SELECT CASE INGROUP("PER") USE G: '\\server\PER' CASE INGROUP("ACD") USE G: '\\server\ACD' ENDSELECT
also, what is the advantage to that '<>' part?
thanks, scsigrrrl99
|
|
Top
|
|
|
|
#20469 - 2002-04-23 08:38 PM
Re: group variable
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
If they are not hidden, no you do not need the $$ at the end. The advantage of the IF "@HOMESHR" <> "" is that if someone doesn't have a home folder defined, the script won't bomb... Just think.. if you do a
USE G: @HOMESHR and @HOMESHR is blank, it will be like:
USE G: "" ... which returns an error. If you can get the @PRIMARYGROUP to work, go for it:
Try:
code:
IF "@HOMESHR" <> "" USE H: @HOMESHR ENDIF SELECT CASE "@PRIMARYGROUP" = "PER" USE G: "\\server\PER" CASE "@PRIMARYGROUP" = "ACD" USE G: "\\server\ACD" ENDSELECT
or
code:
IF "@HOMESHR" <> "" USE H: @HOMESHR ENDIF USE G: "\\server\@PRIMARYGROUP"
If @PRIMARYGROUP is returning nothing, you'll have to go with INGROUP.
Brian
|
|
Top
|
|
|
|
#20470 - 2002-04-23 09:03 PM
Re: group variable
|
scsigrrrl99
Fresh Scripter
Registered: 2002-04-22
Posts: 13
Loc: florida
|
Hmmmm...that is very interesting.
What I would like to know, then, is how the @userid macro gets its information about the user's username? I mean, you don't have to do this:
EX. 1
SELECT CASE @USERID=USER1 use H: "\\server1\user1" CASE @userid=USER2 use H: "\\server1\user2"
you see my point? to put it another way, why should the following work:
EX. 2
$s1="\\server1\" $drive=$s1+@userid use H: $drive
but something like this won't work:
EX. 3
$gr="\\server1\groups\" $gdrive=$gr+@primarygroup use G: $gdrive
how does it know what to do with that "@userid" part in the 2nd example? it knows to get the user's username, because it is a macro (a macro is a function, yes? or no?) defined within the scripting language of kixtart itself. It is essentially pre-programmed by the kixtart gurus to find the user's username when you say "@userid". If it weren't, then you'd end up with errors, like H: trying to map to \\Server1\god-only-knows-what-directory-"@userid"-is-supposed-to-be
So, what I wanna know is, how to use the @primarygroup as a macro, just like you use @userid as a macro. If Kixtart is smart enough to know how to find the user's username when you say "@userid", then shouldn't it be able to find the user's primary group when you say "@primarygroup"? I mean, I didn't make that up. That "@primarygroup" macro is in the manual. But how does it work in a script, exactly? I don't see why you would have to specify its value on every line, as you've suggested:
SELECT CASE @PRIMARYGROUP=("PER") Use G: "\\server1\PER" ...and so on... ENDSELECT
seems to me that that is what a macro is for, to cut down on the busy work of specifying values over and over again.
Anyway, since I need to get this working, I've found a stopping place that gets the job done. Here is my final script:
;Kixtart script for Client ;April 2002
$LC="Legal Notice: Name of Client Organization" $LN="You are signing onto computing and networking services provided by [somebody other than you]. These resources are furnished for the performance of your assigned job responsibilities. You are responsible for ensuring that they are used only for that purpose. You should not have any expectation that your computer files or E-mail transmissions are 'private' in nature."
SELECT CASE @INWIN=2 $rc = ADDKEY("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Winlogon") $rc = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Winlogon", "LegalNoticeCaption", "$LC","REG_SZ") $rc = WriteValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Winlogon", "LegalNoticeText", "$LN","REG_SZ") CASE $rc = ADDKEY("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon") $rc = WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "$LC","REG_SZ") $rc = WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText", "$LN","REG_SZ") ENDSELECT
;---Delete All Previous Drive Mappings-----
use "*" /delete /persistent
;---Declare Variables----------
$s1="\\Server1\" ;file server and home directories $s2="\\Server2\" ;nas box
$hdrive=$s1+@userid ;user's home directory $odrive=$s2+@userid ;user's GroupWise archives directory
;---Map Drives------------------
use H: $hdrive
IF INGROUP("ArchivesGW")=1 use O: $odrive ENDIF
SELECT CASE INGROUP("ACC") USE G: "\\Server1\ACC" CASE INGROUP("ACT") USE G: "\\Server1\ACT" CASE INGROUP("ACD") USE G: "\\Server1\ACD" CASE INGROUP("BUD") USE G: "\\Server1\BUD" CASE INGROUP("CHA") USE G: "\\Server1\CHA" CASE INGROUP("CIG") USE G: "\\Server1\CIG" CASE INGROUP("DSS") USE G: "\\Server1\DSS" CASE INGROUP("EOP") USE G: "\\Server1\EOP" CASE INGROUP("FACTS") USE G: "\\Server1\FACTS" CASE INGROUP("FBOE") USE G: "\\Server1\FBOE" CASE INGROUP("FIN") USE G: "\\Server1\FIN" CASE INGROUP("GEN") USE G: "\\Server1\GEN" CASE INGROUP("ITRS") USE G: "\\Server1\ITRS" CASE INGROUP("IRM") USE G: "\\Server1\IRM" CASE INGROUP("OFP") USE G: "\\Server1\OFP" CASE INGROUP(OHR) USE G: "\\Server1\OHR" CASE INGROUP("OPA") USE G: "\\Server1\OPA" CASE INGROUP("PER") USE G: "\\Server1\PER" CASE INGROUP("SDD") USE G: "\\Server1\SDD" CASE INGROUP("SSD") USE G: "\\Server1\SSD" ENDSELECT
one last thought: I copied and pasted that first part from somebody's Starter's Guide. Is that a no-no? Do I have to cite them, as a co-author?
Whew! That's a lot to say, isn't it?
Thanks again everybody, scsigrrrl99
|
|
Top
|
|
|
|
#20472 - 2002-04-23 09:28 PM
Re: group variable
|
scsigrrrl99
Fresh Scripter
Registered: 2002-04-22
Posts: 13
Loc: florida
|
thank you! that sort of caught my eye as looking strange, but I guess I forgot to pursue it to any degree of detail. I've fixed it now.
I will play around with the @primarygroup thing later this week. I'm about fried on scripting at the moment. Need to take a break from it for today. What I've got gets the job done, at least.
Again, thank you very much for all your help. And thank you for keeping those old posts out there!
scsigrrrl99
|
|
Top
|
|
|
|
#20473 - 2002-05-20 05:02 PM
Re: group variable
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Another way of catching "userid" can be done with following code
code:
$user="" IF (@inwin = 1) $ikey="HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" IF (ExistKey($ikey) = 0) $user=ReadValue($ikey, "DefaultUserName") ENDIF ELSE $ikey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\control" IF (ExistKey($ikey) = 0) $user=ReadValue($ikey, "Current User") ENDIF ENDIF IF (len($user) = 0) $user=@userid IF (len($user) = 0) $user="~user" ENDIF ENDIF ? "user: "+$user
in some situations (depending of windows version running) you doesn't get the right value with "@userid" macro call. In our script logon.kix you can find also information about the way of getting other macro value by only reading related registry keys. You find it on our site http://home.wanadoo.nl/scripting greetings.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|