Page 1 of 2 12>
Topic Options
#38086 - 2003-03-20 10:59 AM HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Kris Offline
Fresh Scripter

Registered: 2003-03-20
Posts: 13
Loc: Belgium
Below is the scripts I made. For drivemappings, I get the servername out of the user's local groups and the sharename out of the user's global groups. PROBLEM: Some users are in several matching local and global groups so they will get the same drivemapping twice. How can I prevent this or delete an identical drivemapping on another driveletter? [Confused]

Break on ; Make this script interruptable using close or ctrl-C
Debug OFF
; cls

; Standard reserved driveletters
$WerkLetter = "GJKL-"
$ApplLetter = "QRP-"
$ProjLetter = "STUV-"

; Get all Local and Global Groups
$arLocal = GetUserLocalGroups()
$arGlobal = GetUserGlobalGroups()

; Set LogonDomain
$strDomain = @LDOMAIN

; walk all Local Groups
For Each $strLocalGroup in $arLocal

;? $strLocalGroup

; Get all Global Groups in this LocalGroup
$arGlobalInLocal = GetGlobalInLocal($strLocalGroup, $strDomain)

; Walk all Global Groups in this LocalGroup
For Each $strGlobalInLocal in $arGlobalInLocal

; ? $strGlobalInLocal

For Each $strglobal in $arGlobal
; ? $strglobal
If $strglobal = $strGlobalInLocal
$line = "\\" + $strLocalGroup + "\" + $strglobal
? $line
EndIf

; Build share name
; MakeMapping($strLocalGroup, $strGlobalLocalGroup)
; Endif
Next
Next
Next

Function GetUserLocalGroups()

$LTeller = 0
Do
$LGroup = EnumLocalGroup($LTeller)
$LTeller=$LTeller+1
$GetUserLocalGroups = $GetUserLocalGroups + ";" +$LGroup
Until Len($LGroup) = 0
$GetUserLocalGroups = Split($GetUserLocalGroups, ";")

EndFunction

Function GetUserGlobalGroups()

$GTeller = 0
Do
$GGroup = EnumGroup($GTeller)
$GTeller=$GTeller+1
$GetUserGlobalGroups = $GetUserGlobalGroups + ";" +$GGroup
Until Len($GGroup) = 0
$GetUserGlobalGroups = Split($GetUserGlobalGroups, ";")

EndFunction

Function GetGlobalInLocal($strLocalGroup, $strDomain)

Dim $i,$error,$line
Dim $array[255]
Dim $ReDim $ReDim = Ubound($array)
Dim $tempfile $tempfile = "%temp%\pipe.tmp"

If Exist("$tempfile")
Del("$tempfile")
EndIf
Shell '%comspec% /c local "$strLocalGroup" "$strDomain" > "$tempfile" 2>nul'
$error = @error
If Open (10, "$tempfile") = 0
$i = 0
$line = ReadLine(10)
While NOT @error
If $line
$array[$i] = $line
If $i = $ReDim
$ReDim = $ReDim*2
ReDim preserve $array[$ReDim]
EndIf
$i = $i + 1
EndIf
$line = ReadLine(10)
Loop
$=Close(10)
Del "$tempfile"
If $i > 0
ReDim preserve $array[$i-1]
$GetGlobalInLocal=$array
Else
$GetGlobalInLocal = 0
EndIf
Exit $error
Else
$GetGlobalInLocal = 0
Exit @error
EndIf

EndFunction

;Parse servername from LocalGroup name
Function GetServerFromLocalGroup($strLocalGroup)

$GetServerFromLocalGroup = SubStr($strLocalGroup, 3, Len($strLocalGroup) - 2)

EndFunction

;Parse ShareName from GlobalGroup name
Function GetShareNameFromGlobalGroup($strGlobalGroup)

$GetShareNameFromGlobalGroup = SubStr($strGlobalGroup, InStr($strGlobalGroup, "_") + 1)

EndFunction

Function CheckStringINArray($arGlobal, $strGlobalLocalGroup)

$CheckStringINArray = 0
For Each $strToCheck IN $arGlobal

?$strToCheck
?$strGlobalGroup
If ($strToCheck == $strGlobalGroup)
$CheckStringINArray = 1
EndIf
Next

EndFunction

Function MakeMapping($strLocalGroup, $strGlobalGroup)

? "Share: \\" + GetServerFromLocalGroup($strLocalGroup) + "\" + GetShareNameFromGlobalGroup($strGlobalGroup)

EndFunction

Top
#38087 - 2003-03-20 01:00 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can build a string for the path e.g. "\\server\share" and push it into a unique array using my HASH() UDFs. Then when you read "keys" from the HASH you will only get unique entries.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#38088 - 2003-03-20 02:07 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Hi Fellas !!
Does anybody know the reason why this twice drivemapping happends? Surely has been already mentioned but i havent seen it. Thanks in advance.

Peace.
_________________________
Life is fine.

Top
#38089 - 2003-03-20 02:20 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
José,

this has been discussed before and I used to know the reason ... can't remember right now (will search)

Peace, man !
_________________________



Top
#38090 - 2003-03-20 02:35 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sorry , but all I could find was some vague root cause guesses about Desktop shortcuts pointing to Applications on mapped drives (As soon as the drive is inactive it can happen that the OS tries to connect to another drive ... I had that once too on NT )

maybe the technet will show up some more background [Confused]
_________________________



Top
#38091 - 2003-03-20 02:42 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
It was FINDFAST [Mad] [Mad] [Mad]
Now I remember to get around this by deleting the Autorun entry and renaming the exe to something really nasty which shouldn't be mentioned here [Big Grin]

here is the Article :

OFF: Drive Letters Automatically Map to Network Drives

hth

Hey Kris, REALLY NICE HP you got there [Smile]

[ 20. March 2003, 14:50: Message edited by: jpols ]
_________________________



Top
#38092 - 2003-03-20 02:50 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
I don't get it.
if you have multiple maps to one share in your script, what is the problem?
just modify your script.

the findfast issue seems totally unrelated as it's about user stuff, not script.
_________________________
!

download KiXnet

Top
#38093 - 2003-03-20 02:57 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I think I answered more José than Kris

Well, call me a Post-Pirate [Razz]
_________________________



Top
#38094 - 2003-03-20 02:57 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Find duplicate drivemappings with DriveProp() - return an array of FSO drive properties , posted in the UDF Forum.

Oh, and please don't shout! (all CAPS subject line)

[ 20. March 2003, 14:58: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#38095 - 2003-03-20 03:09 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Thanks jpols and sorry Kris to change focus on your thread. [Big Grin]
In my case I have seen this behabior and I am oriented to think that tha \\.lnk is doing this cause i disabled deam FINDFAST.
I´ll study udf Jens...thanks dudes.

Peace.
_________________________
Life is fine.

Top
#38096 - 2003-03-20 03:13 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
UNCs can also be mapped automatically if you keep the UNC name inside .LNKs. ScriptLogic has a command-line utility, which removes these UNCs (MAKESCUT.EXE)
_________________________
There are two types of vessels, submarines and targets.

Top
#38097 - 2003-03-20 03:53 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Kris Offline
Fresh Scripter

Registered: 2003-03-20
Posts: 13
Loc: Belgium
Thanx 4 all the efforts so far guys... [Wink]
The problem is not solved yet [Roll Eyes] ... The solution must work on NT4, W2K and XP, so it must'nt use WSH but ONLY kix or a batchjob.

Peace!

Top
#38098 - 2003-03-20 03:56 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The do a NET USE piped (Pipe() UDF) into a tempory file and use the IsStringInFile() UDF to check whether a specific UNC is already present.
_________________________
There are two types of vessels, submarines and targets.

Top
#38099 - 2003-03-20 04:40 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Kris, did I misunderstand your problem. when Iread your original post I thought that the script you used and the methodology of using the groups had your script attempt to map the same share name more than one time. If this is a scripting issue my suggestion would eliminate the the duplicate attempts to map the same drive.

If you problem is not that you code is making multiple attempts to map the same drive, and it is in fact that multiple drives appear to be mapped to the same server\share location that is not a result of your script, then you issue in not your script. Please clarify which problem you are experiencing.

Include writing a logfile of all mapping activity in your script, how does that compare with the drives currnely mapped after the logon script has finished? Are the extra drives always to the same location?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#38100 - 2003-03-25 01:36 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Kris Offline
Fresh Scripter

Registered: 2003-03-20
Posts: 13
Loc: Belgium
I think Howard Bullock has a pretty good solution with his HASH (UDF) function but I still didn't manage to get the script to work with HASH (UDF). Perhaps the complexity is too high...
Top
#38101 - 2003-03-25 01:57 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Nothing is too complex. Simply write more complex code. [Wink]

I have to study your original post to determine exactly what it is you are doing. I may have time to review it some time this morning.

[ 25. March 2003, 13:57: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#38102 - 2003-03-25 02:18 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Let me see if I understand what you are attempting to do...

1. You have global groups (named using a share name) that contain people that can access a given server.

2. You have local groups on a server (named after servers) that contain people that can access a given share.

3. The local group can contain global groups - why?

Please describe the business/security process you want to employ.

Please confirm that the problem of the duplicate groups arises from the fact that the person is a member of a global group and that the same of different global group containing the same person is also located in the local group.

{edit} changed #1 and #2. Had Group to server/share relation reversed.

[ 25. March 2003, 14:30: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#38103 - 2003-03-25 02:29 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Kris Offline
Fresh Scripter

Registered: 2003-03-20
Posts: 13
Loc: Belgium
Howard,

Local groups do contain global groups and the group policy is unchangeable since this is a script for the belgian and european government. The roots of the organisation are soo deep [Eek!] [Eek!] [Eek!] , that no-one will change this before we start an Active Directory rollout next year... So the only solution for now and the future is make this script work for all the departments of the gouvernments. Do you know how to configure you're HASH (udf) in this script to remove or prevent potentially double drive mappings? [Confused]

Top
#38104 - 2003-03-25 02:37 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think so.

This is what I have so far:
code:
Function GetServerFromLocalGroups()
Dim $LTeller, $LGroup
$LTeller = 0
Do
$LGroup = EnumLocalGroup($LTeller)
$LTeller=$LTeller+1
Hash("MyShares", SubStr($LGroup, InStr($LGroup, "_") + 1, 1)
Until Len($LGroup) = 0
EndFunction

Function GetSharesFromGlobalGroups()
Dim $GTeller, $GGroup
$GTeller = 0
Do
$GGroup = EnumGroup($GTeller)
$GTeller=$GTeller+1
Hash("MyServers", SubStr($GGroup, 3, Len($GGroup) - 2, 1)
Until Len($GGroup) = 0
EndFunction

This code replaces several of your original functions.

What needs to be worked on now is the listing of the global groups in locals groups and adding the additional shares (from Global groups names) to the "MyShares" HASH.

Then you simply:
code:
For each $Server in HashKeys("MyServers")
For each $Share in HashKeys("MyServers")
use $drive "\\"+$Server+"\"+$Share
next
next

I haven't quite figured out where you link the drive letter to the server\share yet.

Does this seem to be going in the right direction?

[ 25. March 2003, 14:38: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#38105 - 2003-03-25 02:42 PM Re: HOW CAN I REMOVE/PREVENT DOUBLE DRIVEMAPPINGS?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This seems somewhat confusing and potentially links inappropriate server names to the wrong shares.

Can you provide more detail in the actually naming conventions of the groups (local and global) so that we can understand your implementation better?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.046 seconds in which 0.018 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