Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Script Not Detecting User In Group

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2297
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script Not Detecting User In Group
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Script Not Detecting User In Group - 3/9/2005 10:01:53 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, below is a copy of my login script.

Myself and 3 other guys are part of the London Systems NT group which should map the following drives

MapDrive "I:", "\\Hyperion\itstuff"
MapDrive "Y:", "\\poseidon\home$"
MapDrive "Z:", "\\zeus\zenapps"

Only the vbs script does not think that they are part of the London Systems NT Group and does not map the drives. It maps them ok for me!

We are running Windows NT4 Domain

Any ideas why it would not think they are part of the Group?

-----------------------


On Error Resume Next
Dim WshNetwork, asdPath, User
Dim strMappedDrives, strStatus
Dim IE
Dim objFSO

set shell = createobject("wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Const ADS_READONLY_SERVER = 100

' Display IE status window

Call CreateIE()
strStatus = "Please call x6440 with any Login issues " & Date()
ie.document.all.wstatus.InnerText = strMsg3

' Get the User ID

Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUser = ""
While strUser = ""
strUser = WSHNetwork.UserName
Wend

ie.document.all.Msg1.InnerText = strUser

call main()

strStatus = strStatus & vbCRLF & "Withers LLP London Network Logon Complete..."
ie.document.all.wstatus.InnerText = strStatus


' Close IE status window

If not ie.document.all.holdit.checked then
ie.quit()
End if

' End of logon script

Public Sub Main()

'Main loop to detect group that user belongs to
adsPath = "WinNT://London/" & strUser
Set dso = GetObject("WinNT:")
Set objUser = dso.OpenDSObject(adsPath,"","", ADS_READONLY_SERVER)
For Each Prop In objUser.groups
Select Case Prop.Name

Case "Domain Users"
Call DomainUsers()

Case "Photos"
Call Photos()

Case "DigitalPhotos"
Call DigitalPhotos()

Case "Helpdesk"
Call Helpdesk()

Case "London Systems"
Call LondonSystems()

'etc
End Select
Next 'Prop

End Sub

Sub DomainUsers()

strStatus = strStatus & vbCRLF & "Member of London Domain Users..."
ie.document.all.wstatus.InnerText = strStatus

shell.run ("net time \\atlas /set /yes")

MapDrive "S:", "\\poseidon\data"
MapDrive "V:", "\\poseidon\apps"

shell.run ("net use \\zeus\zenapps")
shell.run ("net use \\atlas\crispdata")

objFSO.CopyFile "\\zeus\zenapps\nav\grc.dat", "C:\Documents and Settings\All Users\Application Data\Symantec\Symantec AntiVirus Corporate Edition\7.5\"

shell.run ("cmd /c attrib -h c:\program files\Microsoft Office\office\startup\*.*"),0,true

End Sub

Sub Photos()

strStatus = strStatus & vbCRLF & "Member of Photos Group on HEBE..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "P:", "\\hebe\photos"

End Sub

Sub DigitalPhotos()

strStatus = strStatus & vbCRLF & "Member of JDM DigitalPhotos on HEBE..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "Q:", "\\hebe\digitalphotos"

End Sub

Sub Helpdesk()

strStatus = strStatus & vbCRLF & "Member of ITSTUFF on HYPERION..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "I:", "\\Hyperion\itstuff"
MapDrive "Y:", "\\poseidon\home$"
MapDrive "Z:", "\\zeus\zenapps\withersdocs.ini"

End Sub

Sub LondonSystems()

strStatus = strStatus & vbCRLF & "Member of London Systems Team..."
ie.document.all.wstatus.InnerText = strStatus

MapDrive "I:", "\\Hyperion\itstuff"
MapDrive "Y:", "\\poseidon\home$"
MapDrive "Z:", "\\zeus\zenapps"

End Sub

Sub CreateIE()

On Error Resume Next
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate "\\atlas\netlogon\uk\logon.htm"
.resizable=0
.height=470
.width=350
.menubar=0
.toolbar=0
.statusBar=0
.visible=1
End With

SecondsToDelay = "2"
Wscript.Sleep(SecondsToDelay * 2000)

End Sub

Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, strShare

If Err.Number Then

WSHNetwork.RemoveNetworkDrive strDrive
WSHNetwork.MapNetworkDrive strDrive, strShare

End If

strMappedDrives = strMappedDrives & strDrive & " "
ie.document.all.Msg2.InnerText = strMappedDrives

End Sub
 
 
Post #: 1
 
 Re: Script Not Detecting User In Group - 3/9/2005 11:38:22 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
I really cant see what the issue with it is? , it works for some users and not others.

Any ideas would be great if poss

Thanks in advanced

(in reply to cjwallace)
 
 
Post #: 2
 
 Re: Script Not Detecting User In Group - 3/9/2005 11:40:08 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Are you getting any kind of error when the drives don't map? Have you tried removing the error resume next? Also, you might want to check and make sure that london systems is showing up correctly. Try somehthing like this;

If struser = "user1" or struser = "user2" or strUser = user3" then
Msgbox "-" & prop.Name & "-" & vbcr & "London Systems"
End if
The reason for the - is to verify that there are no additional characters. And even if it is working for you and not them, I would still check this out.

(in reply to cjwallace)
 
 
Post #: 3
 
 Re: Script Not Detecting User In Group - 3/10/2005 12:08:56 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Mbouchard: Thanks for the reply. No no error messages when the drives dont map. I have removed the error resume next but it still does not map or display an error message

Its odd that it works for me and not others in the same group.

The bit of code you asked me to try, does that go in my login script or in a new .vbs file to run?

(in reply to cjwallace)
 
 
Post #: 4
 
 Re: Script Not Detecting User In Group - 3/10/2005 12:19:23 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
you could add it to your login script or just add some of the login script code and have the other guys run it to see what they get.

(in reply to cjwallace)
 
 
Post #: 5
 
 Re: Script Not Detecting User In Group - 3/10/2005 12:24:31 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Mbouchard: I have put your code into a new .vbs file and run it but it does not do anything. I have changed the "user2" to the users login eg "abc"

Also a small spanner in the works. If i get the users to log onto a computer they have not been to before with a fresh profile all the drives map ok.

Any ideas as to what is stopping it on there machines?

Thanks for all your help so far mate

(in reply to cjwallace)
 
 
Post #: 6
 
 Re: Script Not Detecting User In Group - 3/10/2005 1:09:28 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Try deleting all network drives before mapping drives

'************************************************
'DELETE ALL NETWORK DRIVES
'************************************************
Set Drives = WshNetwork.EnumNetworkDrives
If Drives.count = 0 then
'msgbox "There are no drive mappings at this time."
Else
For x = 0 to Drives.count-1 Step 2
wshNetwork.RemoveNetworkDrive Drives.Item(x),bForce, bUpdateProfile
Next
End If

(in reply to cjwallace)
 
 
Post #: 7
 
 Re: Script Not Detecting User In Group - 3/10/2005 1:18:26 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
tnoonan: Thanks for the reply. We defo did delete all the drives before they were mapped , really cant work out why these drives dont map

Any other ideas?

Thanks in advanced

(in reply to cjwallace)
 
 
Post #: 8
 
 Re: Script Not Detecting User In Group - 3/10/2005 2:11:57 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Whats odd now is, i deleted all my map drives and re-run the logon.vbs but it has not mapped any of the drives assigned to London Systems on the drives to domain users

What the hell is going on?

Do you think windows has got a lock on somewhere?

(in reply to cjwallace)
 
 
Post #: 9
 
 Re: Script Not Detecting User In Group - 3/10/2005 2:27:24 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
I have run the below code for the users in my systems group and it comes back and tells me there are in that group

Why would windows be stopping the drives from mapping?

dsRoot = "WinNT://london/USERNAME"
set wshShell = Wscript.CreateObject("Wscript.Shell")
set dsObj = GetObject(dsRoot)
For Each Prop In dsobj.groups
wshshell.popup Prop.Name
Next 'Prop

(in reply to cjwallace)
 
 
Post #: 10
 
 Re: Script Not Detecting User In Group - 3/10/2005 2:33:52 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hows this for odd, I put my self into one of the other groups and they all came back. , but i still cant get the other guys drives to map......Any ideas?

(in reply to cjwallace)
 
 
Post #: 11
 
 Re: Script Not Detecting User In Group - 3/10/2005 3:03:33 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, I have been told by someone else to change my code to the following

Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, strShare

If Err.Number = -2147024811 Then
Err.clear
WSHNetwork.RemoveNetworkDrive strDrive, True, True
WSHNetwork.MapNetworkDrive strDrive, strShare
Else
WScript.Echo Err.Number & " " & Err.Description
Err.clear
End If

strMappedDrives = strMappedDrives & strDrive & " "
ie.document.all.Msg2.InnerText = strMappedDrives

End Sub


When i then run the login script i get two box up with 0 in them, does anyone know what they mean?

Cheers

(in reply to cjwallace)
 
 
Post #: 12
 
 Re: Script Not Detecting User In Group - 3/10/2005 4:07:47 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
First of all, I assume that's a typo and ahs been fixed ?

MapDrive "Z:", "\\zeus\zenapps\withersdocs.ini"

Also, instead of the following:

adsPath = "WinNT://London/" & strUser
Set dso = GetObject("WinNT:")
Set objUser = dso.OpenDSObject(adsPath,"","", ADS_READONLY_SERVER)

I would suggest to use the following:

Set objUser = GetObject("WinNT://London/" & strUser & ",user")

You might also want to echo the groups a user belongs to within the loop and use others userID to login to see if the scripts actually loops through all their groups etc.

(in reply to cjwallace)
 
 
Post #: 13
 
 Re: Script Not Detecting User In Group - 3/10/2005 7:40:23 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token: Thanks for the reply. No it was not a typo we do have a folder called withersdocs.ini, was there before my time! but i can see your point and have changed the directory to just withersdocs

Cheers for the other point i will give it a go when i get into work tomorrow, The whole thing is driving me mad to be honest as i really want to put the script live to all 500 users but cant until i get this issue working.

i will be in touch

Thanks again for your help

(in reply to cjwallace)
 
 
Post #: 14
 
 Re: Script Not Detecting User In Group - 3/10/2005 7:47:21 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
What a EVIL directory name!

and you're welcome. Let's hope that solves the problem :)

(in reply to cjwallace)
 
 
Post #: 15
 
 Re: Script Not Detecting User In Group - 3/10/2005 8:31:09 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token:, Hi mate, I have made the changes as per your post but still when certain users login the login script is not mapping all the drives. It seems to only map the drives for the Domain Users but no other groups

Is there anything else i could try?

Cheers for your help

(in reply to cjwallace)
 
 
Post #: 16
 
 Re: Script Not Detecting User In Group - 3/11/2005 12:05:30 AM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
Let's go back to your original post and for the moment, forget everything that transpired subsequently.
1. Does that exact situation still exist (i.e. the script works fine for you, but not others)?
2. If true, can you manually map these drives from the others computers?
3. If yes, then the problem is as you conjecture, that the script does not recognize them as belonging to a certain group, and consequently, the mapping code never gets called.

You must determine which is the case (mapping does not work or group identity does not work). Once you narrow down which of the two cases it is, then we can narrow down from there.

Don't forget to use the technique of hardcoding stuff that would otherwise be done programmatically within test scripts as a good way of isolating a problem.

(in reply to cjwallace)
 
 
Post #: 17
 
 Re: Script Not Detecting User In Group - 3/11/2005 12:11:34 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Beaker, thanks for the reply.

1) Yes The problem still exist in that the script will map all the drives which NT Group i belong to , but it will not work for others.

2)Yes i can manually map the drives from the other computers from the command line or from a batch file

3)Well i think it could be group identity does not work , but could it be the code?

Thanks for your reply and time, Look forward to yours or others replys

Cheers

(in reply to cjwallace)
 
 
Post #: 18
 
 Re: Script Not Detecting User In Group - 3/11/2005 12:32:18 AM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
OK, setup some smaller test scripts. The first one will hardcode the group identity and map the drives. No conditional statements. Just force it. If that works, create a second test script that just gets the group identity. Again, no conditional statements. Run it on your machine then on one of problem machines. If that does not work, then some fundamental difference exists between the computers, and this is probably not a scripting problem.

(in reply to cjwallace)
 
 
Post #: 19
 
 Re: Script Not Detecting User In Group - 3/11/2005 1:04:07 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Beaker: Sorry, i am so new to vb that i dont know how i would take apart my script as you said?

From my script can you reply with what code i need for my test script?

I am really sorry but i have pulled my script originally from lots of different places to make it what it is now

(in reply to cjwallace)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script Not Detecting User In Group Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts