jazzyjeff Posted September 20, 2010 Share Posted September 20, 2010 Hello I have written a login script and it is working fine. I am running into a situation though where I need to use the AND/OR operators. Here is an example of what I have: #include<AD.au3> If _AD_IsMemberOf("Group1",@username) Then DriveMapAdd("E:","") DriveMapAdd("F:","") DriveMapAdd("G:","") ElseIf _AD_IsMemberOf("Group2, @username) And _AD_IsMemberOf("Group1, @username) Then DriveMapAdd("H:","") DriveMapAdd("I:","") DriveMapAdd("J:","") ElseIf _AD_IsMemberOf("Group3, @username) And _AD_IsMemberOf("Group4, @username) Or _AD_IsMemberOf("Group2, @username") Or _AD_IsMemberOf("Group5, @username") Then DriveMapAdd("N:","") DriveMapAdd("O:","") DriveMapAdd("P:","") EndIf The part I am having problems with is the last part of the "ElseIf" statement. I am basically asking to check if the user logging in is a member of the "Group3" and any of the following: Group 4 Group 2 Group 5 Then it will map a different set of drives. The other parts of the If statememnts work, but I just can't get it to work properly when I mix the "AND" and "OR" operators in the same ElseIf statement. How can I get this to work? Thanks, Link to comment Share on other sites More sharing options...
ajag Posted September 20, 2010 Share Posted September 20, 2010 Hi jazzyjeff,I would say: Just use brackets (like in math):ElseIf _AD_IsMemberOf("Group3, @username) And ( _AD_IsMemberOf("Group4, @username) Or _AD_IsMemberOf("Group2, @username") Or _AD_IsMemberOf("Group5, @username") ) ThenA-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
Bert Posted September 20, 2010 Share Posted September 20, 2010 You may be better to use select/case statements. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 20, 2010 Share Posted September 20, 2010 You have another problem too, namely that the first ElseIf doesn't do anything. ElseIf 2 And 1. But if 1 was true, then the earlier If would be executed. You need to Change the place of them! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 20, 2010 Author Share Posted September 20, 2010 Thanks A-Jay. I'll give that a try. MPH, thanks for your reply. When I started creating this login script I was hoping to use SELECT CASE, as I thought it would execute more efficiently. Unfortunately the script kept failing. I ended up setting the script up with If Statements and it works fine. Just had a problem with this bit. I work for a school and this is a crazy time of year as the teachers appear to have forgotten how to use a computer after their long summer! Once things settle down I'll try and get the SELECT CASE working. Thanks again. Link to comment Share on other sites More sharing options...
Varian Posted September 20, 2010 Share Posted September 20, 2010 (edited) How is the 2nd condition ever true? If you are in Group2 and Group1, wouldn't you be meet the first condition (Group1 only) and never see the second condition (Group2 & Group1)? The way that I am thinking it should work is like this.Select Case _AD_IsMemberOf("Group1", @UserName) DriveMapAdd("E:", "") DriveMapAdd("F:", "") DriveMapAdd("G:", "") ContinueCase Case _AD_IsMemberOf("Group2", @UserName) If _AD_IsMemberOf("Group1", @UserName) Then DriveMapAdd("H:", "") DriveMapAdd("I:", "") DriveMapAdd("J:", "") EndIf ContinueCase Case _AD_IsMemberOf("Group3", @UserName) If _AD_IsMemberOf("Group4", @UserName) Or _AD_IsMemberOf("Group2", @UserName) Or _AD_IsMemberOf("Group5", @UserName) Then DriveMapAdd("N:", "") DriveMapAdd("O:", "") DriveMapAdd("P:", "") EndIf EndSelect Edited September 20, 2010 by Varian Link to comment Share on other sites More sharing options...
ajag Posted September 20, 2010 Share Posted September 20, 2010 BTW: Your quotes '"' are ...hmmm....! Look yourself! Or is this not your original code? ElseIf _AD_IsMemberOf("Group2, @username) And _AD_IsMemberOf("Group1, @username) Then ^ ^ ElseIf _AD_IsMemberOf("Group3, @username) And _AD_IsMemberOf("Group4, @username) Or _AD_IsMemberOf("Group2, @username") Or _AD_IsMemberOf("Group5, ^ ^ ^ ^ ^ @username") Then ^ should'nt this be ElseIf _AD_IsMemberOf("Group2" @username) And _AD_IsMemberOf("Group1", @username) Then ElseIf _AD_IsMemberOf("Group3", @username) And _AD_IsMemberOf("Group4", @username) Or _AD_IsMemberOf("Group2", @username) Or _AD_IsMemberOf("Group5", @username) Then ? A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 20, 2010 Author Share Posted September 20, 2010 (edited) Hi AJay, I am waiting to hear back about the script. That wasn't my original code, just something to give you an idea of what I am trying to achieve. I just made a typo. Varian, As I say I haven't had a chance to get the SELECT CASE working as I need yet, but I'll be sure to try this as I think it's the way to go. Here is my proper code, but I warn you now... It is VERY long for a login script. Works fast though. Edited September 20, 2010 by jazzyjeff Link to comment Share on other sites More sharing options...
Varian Posted September 20, 2010 Share Posted September 20, 2010 Can you edit that post with line breaks...use the Full Editor and copy/paste will work with line breaks. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 20, 2010 Share Posted September 20, 2010 @jazzyjeff When you press the AutoIt-button just press add and paste the code in afterwards or you get this mess. Also use the preview button, then you would have seen the mess before posting it. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 20, 2010 Author Share Posted September 20, 2010 Sorry peeps. I have added enough code on here to know how it works. I don't what's wrong with it, but I have tried your suggestions and it won't paste properly. It's starting to **** me off to be honest :-) I just removed it now anyway, so my "Mess" should no longer clutter this post. I'll try again in a bit and see if it will work in FF. Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 20, 2010 Author Share Posted September 20, 2010 Still not working in FF... Ah well. Maybe it's too long, or there's a character in there that's messing things up. Hopefully my colleague will get back to me about the login script and I'll let you know how it goes with those suggestions. Thanks All! Link to comment Share on other sites More sharing options...
jazzyjeff Posted September 21, 2010 Author Share Posted September 21, 2010 Thank you all for your help. Adding the parenthesis as suggested by AJay resolved the issue. I'll start working shortly using the SELECT CASE though. Also, I tried pasting another script into the forum and it worked fine. Just something in my script is breaking the code function in this site. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now