Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Re: 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 >> Re: Script Not Detecting User In Group
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 Re: Script Not Detecting User In Group - 3/11/2005 1:18:12 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Only DOmain Users are getting the drives mapped could be because you use SEELCT CASE statement in which if one of the conditions are true (and therefore the associated lines are executed), the rest (more precisely, conditions below it) are ignored.

If you have users belongs to all 5 groups, you should use:

if Prop.Name = "Domain Users" then
Call DomainUsers()
end if
if prop.name = "Photos" then
Call Photos()
end if
if.... then
end if
if.... then
end if
if.... then
end if

(in reply to cjwallace)
 
 
Post #: 21
 
 Re: Script Not Detecting User In Group - 3/11/2005 1:25:31 AM   
  Bushmen

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
cjwallace,

i can not see much wrong with your script, although you really need to troubleshoot your script more as per Beaker's comments.

A good way to troubleshoot your script is to use a good debugger. Then add watches to Variables and see what your script is really doing.

If you don't have access to a good debugger, then something as simple as message boxes, can be of great help.

Maybe change
---------------------------------
For Each Prop In objUser.groups
Select Case Prop.Name
---------------------------------
to
---------------------------------
For Each Prop In objUser.groups
Msgbox Prop.Name
Select Case Prop.Name
---------------------------------

This way you can see if the script recognises the correct group/s.

Then, if you are happy that that is working, add another messagebox to every sub,
so that you can see if the sub is running..

I know this is very basic stuff, but you need to take small steps at a time in your script when troubleshooting, rather than looking at a couple of pages of code looking for a problem.

Bushmen

(in reply to cjwallace)
 
 
Post #: 22
 
 Re: Script Not Detecting User In Group - 3/11/2005 1:46:09 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
quote:
Originally posted by token

Only DOmain Users are getting the drives mapped could be because you use SEELCT CASE statement in which if one of the conditions are true (and therefore the associated lines are executed), the rest (more precisely, conditions below it) are ignored.

If you have users belongs to all 5 groups, you should use:

if Prop.Name = "Domain Users" then
Call DomainUsers()
end if
if prop.name = "Photos" then
Call Photos()
end if
if.... then
end if
if.... then
end if
if.... then
end if





Token: Thanks for the reply mate, I have changed my code as per your message and must say it looks nice to have it that way rather than the way before, But it has not solved the issue.

Thanks for your help so far mate , is there anything else i could try?

(in reply to cjwallace)
 
 
Post #: 23
 
 Re: Script Not Detecting User In Group - 3/11/2005 1:48:37 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
quote:
Originally posted by Bushmen

cjwallace,

i can not see much wrong with your script, although you really need to troubleshoot your script more as per Beaker's comments.

A good way to troubleshoot your script is to use a good debugger. Then add watches to Variables and see what your script is really doing.

If you don't have access to a good debugger, then something as simple as message boxes, can be of great help.

Maybe change
---------------------------------
For Each Prop In objUser.groups
Select Case Prop.Name
---------------------------------
to
---------------------------------
For Each Prop In objUser.groups
Msgbox Prop.Name
Select Case Prop.Name
---------------------------------

This way you can see if the script recognises the correct group/s.

Then, if you are happy that that is working, add another messagebox to every sub,
so that you can see if the sub is running..

I know this is very basic stuff, but you need to take small steps at a time in your script when troubleshooting, rather than looking at a couple of pages of code looking for a problem.

Bushmen



Bushmen: , Thanks for your message. I have changed my code as per your message. When i run the script i get a box with all the groups the script thinks the user is in, when i run it on mine it tells me all the groups i am a member of but when i run it on my work mates computer it only displays Domain Users

Is there anything else i could try?

Is there any good free debuggers i could try?

Thanks again for your help so far

(in reply to cjwallace)
 
 
Post #: 24
 
 Re: Script Not Detecting User In Group - 3/11/2005 6:31:47 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Could you post your latest code (with changes made from the suggestions from others) so we can take a look at the new "version" of the code in its entirely ?

(in reply to cjwallace)
 
 
Post #: 25
 
 Re: Script Not Detecting User In Group - 3/11/2005 6:44:08 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
"Guys, below is a copy of my login script..........." Is it actually a logon script ? If so, why do you have codes related to IE in it ?

(in reply to cjwallace)
 
 
Post #: 26
 
 Re: Script Not Detecting User In Group - 3/11/2005 12:20:33 PM   
  Bushmen

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
yeah, post the code.

the grouping is obviously an issue. are these users definately in other groups in AD?

Maybe log on to their computer with your logon account and see if it works, let them log on to your box, see what you get.. you've got to do a few tests and give us more information..

regarding debuggers,...

microsoft script debugger is good enough..i think it comes with office...also try to use good script editors.. i.e. editplus, primalscript..

bushmen

(in reply to cjwallace)
 
 
Post #: 27
 
 Re: Script Not Detecting User In Group - 3/11/2005 9:49:13 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, Thanks for your reply:

Token: it is a login script that once runs opens an IE Windows to display what groups the users are in and what drives its mapping etc , then it shuts the IE window down.

Bushman: I have done a further bit of testing this morning, If i log into one of my work mate computer i only get mapped the drives that are for Domain users & not the rest of the drives that i am a member of , also if i log one of my work mates into my computer they get all the mapped drives according to there groups.

Below is an up to date copy of the login script with all changes made to date.

Thanks to everyone who is trying to help me with this


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 = 5

' 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
Set objUser = GetObject("WinNT://London/" & strUser & ",user")
Set dso = GetObject("WinNT:")
For Each Prop In objUser.groups
rem Msgbox Prop.Name

if Prop.Name = "Domain Users" then
Call DomainUsers()
end if

if Prop.Name = "Photos" then
Call Photos()
end if

if Prop.Name = "DigitalPhotos" then
Call DigitalPhotos()
end if

if Prop.Name = "Helpdesk" then
Call Helpdesk()
end if

if Prop.Name = "Systems" then
Call Systems()
end if

'etc

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 Systems()

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

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

(in reply to cjwallace)
 
 
Post #: 28
 
 Re: Script Not Detecting User In Group - 3/11/2005 9:50:48 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Bushman: also we are not using AD yet , will be going live with it in two months. At the moment we are running NT4 Server with 2000 desktops and laptops.

(in reply to cjwallace)
 
 
Post #: 29
 
 Re: Script Not Detecting User In Group - 3/12/2005 1:43:33 AM   
  beaker

 

Posts: 78
Score: 0
Joined: 1/27/2005
From: USA
Status: offline
I am an electronics guy, not a computer guy, but this sounds like an issue of network theory, not script. You need to be absolutely clear in your problem statement. It sounds like you are attempting a roving profile, which may not be possible with the limitations of your current technology. Let my take a stab at declaring your problem statement, and if accurate, I will step out of this thread and let the computer people get it from here:

Problem Statement:
When I log onto my computer with my credentials the script works fine. When another user within the London Systems group logs onto his or her machine with his or her credentials, the locally-run script works fine. When I log onto another user's machine within the London Systems group with my credentials, the script only maps a subset of drives.

(in reply to cjwallace)
 
 
Post #: 30
 
 Re: Script Not Detecting User In Group - 3/12/2005 5:30:52 AM   
  Bushmen

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
hmm..

so, what you're saying is that your script works on your computer with ALL the user accounts, but not for any accounts on their pc's.

I do agree with Beaker, if the script works, that mean its not a coding problem, and must be a network issue.

are you sure this computer is currently a member of the domain?
is it possible that you're logging on with local account information that was saved on a previous successful logon attempt.

Do you use roaming profiles?

If so, this should not matter.. though, this is a silly thing to do, but have you tried taking the computer out of the domain and re-adding it into the domain.

then logging on with your accounts to test the script.

regards,
bushmen

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

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
just a quick thing which doesn't have anything to do with your problem..


in your map drive sub..

why are you mapping the same drive 2 times


--------------------------------
Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive 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
-------------------------------

bushmen

(in reply to cjwallace)
 
 
Post #: 32
 
 Re: Script Not Detecting User In Group - 3/12/2005 9:41:32 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I would suggest the following:

Echo something above each of the line that calls the individual subroutines within the 5 IF Statements to determine whether the script actually went through them or if not, where it stopped.

With the IF statement block for "Domain Users", add addition echo below the "call ...." line to determine whether it actually exited the function.

If everyone, including yourself and your co-workers, had no problem with the scripts while logging on to the domain from your machine, I think it's safe to assume that the scripts works under "normal" conditions. What we have to find out is that what the difference is between your co-work's machine (all of your co-workers' machine or just ONE of them ?) and your machine.

I guess is that when using your co-worker's machine to logon to the domain, the DomainUsers() function exited with some errors. After you determine what function the script stopped at, you can then add more ECHOs within the function to determine at exactly what line the script failed to execute.

Again, was it just one co-worker's machine or ALL of them (except yours) that the script won't work properly regardless of who logged on ?

(in reply to cjwallace)
 
 
Post #: 33
 
 Re: Script Not Detecting User In Group - 3/13/2005 11:53:31 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
quote:
Originally posted by Bushmen

just a quick thing which doesn't have anything to do with your problem..


in your map drive sub..

why are you mapping the same drive 2 times


--------------------------------
Sub MapDrive(strDrive,strShare)

On Error Resume Next
WSHNetwork.MapNetworkDrive 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
-------------------------------

bushmen



Hi Bushman: I am not sure why that was there but i have removed it

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

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
To be honest guys, I think i might knock this problem on the head. If i blow the users roaming profile away or log them onto another computer the problem goes away. We are about 2 months away from getting AD up and running and all our users are going to get new build computers and new profiles so it should not be an issue.

I was really hoping to roll it out to the whole firm in the mean time , but i think i will just wait now.

Can i say Thanks to everyone who has tried to help me solve this problem you have all been a great help to me. I am sure i will be posting more subjects on how to do things.

Cheers everyone

(in reply to cjwallace)
 
 
Post #: 35
 
 Re: Script Not Detecting User In Group - 3/14/2005 3:45:50 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
So romaing profile on that specific ONE computer stopped the script from functioning normally ?

Interesting issue. I wonder what the REAL cause is behind the scene.

and you are welcome =)

Cheers.

(in reply to cjwallace)
 
 
Post #: 36
 
 Re: Script Not Detecting User In Group - 3/14/2005 11:07:37 AM   
  Bushmen

 

Posts: 122
Score: 0
Joined: 2/4/2005
From:
Status: offline
not a problem and good luck.

yeah, i am quite interested in that too..

bushmen

(in reply to cjwallace)
 
 
Post #: 37
 
 
Page:  <<   < prev  1 [2]
 
  

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 >> Re: Script Not Detecting User In Group Page: <<   < prev  1 [2]
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