Permalänk
Medlem

loginscript VB

Hej.

Jag behöver lite hjälp med ett loginscript gjort i VB. Det jag har fått ihop i nuläget för en utav de som ska mappas är förljande:
--------------
Option Explicit

Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")

Dim strDriveLetter
Dim strRemotepath
Dim UserName

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

strDriveletter ="I:"
strRemotepath= "\\SERVER\MAPP"

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

IF UserName ="user2" then objNetwork.RemoveNetworkDrive "I:"
ElseIF UserName ="user1" then objNetwork.RemoveNetworkDrive "I:"
End IF
-----------
Alltså, I: ska mappas för alla, förutom User1 och User2, finns säkert smartare sätt att göra detta på men det här funkar...nästan. Problemet är att det finns en tredje användare som är medlem i samma security group som user1 och user2. I: tas bort även för den användaren (vi kallar honom User3).

Är det någon som vet vad som är fel? Det verkar som att den tar bort I: för alla som är medlem i jusst den security groupen. Jag är ute efter att bara ta bort mappningen för user1 och user2 som sagt.

Jag är helt grön på Visual Basic så om någon vänlig själ skulle sitta på en lösning till mitt problem så skulle jag uppskatta det oerhört mycket.
Tack!

Permalänk

kan inte direkt hjälpa till, men här är en kod jag använder till login-program
för VB2005:

'Rickythemaniac login system
'This code right here is for the "CREATE ACCOUNT" button.

'Check if the " Account Folder " Exists.
If My.Computer.FileSystem.DirectoryExists("C:\Accounts\") = True Then
'If it does Exist, Do nothing!
Else
' If it does NOT! exist, Create the folder.
MkDir("C:\Accounts")
End If
'Check if THE Account the user is making already Exists.
If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox1.Text + "\") = True Then
'If it does! Show an ERROR message.
MsgBox("Error, Account is already in Use", MsgBoxStyle.Critical)
Else
'Check if the Username is Empty
If TextBox1.Text = "" Then
'if it is Empty, Show an Error Message.
MsgBox("Error, Your Account Must have at least 1 Letter in it.", MsgBoxStyle.Information)
Else
'Check if they inputed a Password for their Account.
If TextBox2.Text = "" Then
'If they did Not input a Password, Show an Error message.
MsgBox("Error, Please Input a Password for your Account")
Else
'If they Did everything Correctly, The Account Will be created.
MkDir("C:\Accounts\" + TextBox1.Text)
Dim Username As New System.IO.StreamWriter("C:\Accounts\" + TextBox1.Text + "\" + "Username.txt")
Username.Write(TextBox1.Text)
Username.Close()
Dim Password As New System.IO.StreamWriter("C:\Accounts\" + TextBox1.Text + "\" + "Password.txt")
Password.Write(TextBox2.Text)
Password.Close()
Me.Close()
End If
End If
End If

'If Username is Empty
If TextBox1.Text = "" Then
'Show an Error Message.
MsgBox("Error, You need at least 1 Letter on your Username.")
Else
'Check if the Account you are trying to log into, Exists.
If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox1.Text + "\") Then
'Create some Variables that will be used, to read the Username/Password Text Files.
Dim Userread As New System.IO.StreamReader("C:\Accounts\" + TextBox1.Text + "\" + "Username.txt")
Dim Userline As String

Dim Passread As New System.IO.StreamReader("C:\Accounts\" + TextBox1.Text + "\" + "Password.txt")
Dim Passline As String
Do
Passline = TextBox2.Text
Userline = Userread.ReadLine()
Console.WriteLine(Passline)
Console.WriteLine(Userline)
Loop Until Userline Is Nothing

'If Password is Empty
If TextBox2.Text = "" Then
'Give an Error Message.
MsgBox("Error, Please Input Password", MsgBoxStyle.Critical)
Else
'Check if the Password you inputed, Matches the one on the Textfile
'If it does, Congrats.
If Passline = Passread.ReadLine() = True Then
'Show a Welcome Message if the Password is Correct.
MsgBox("Welcome to the System " + TextBox1.Text + "!.")
Else
'Show a message stating Password is INCORRECT
MsgBox("Incorrect Password; Sorry " + TextBox1.Text, MsgBoxStyle.Information)
End If
End If
Else
'If! the Account Does NOT! exist. Show an Error Message.
MsgBox("Error, That Username Does Not Exist.", MsgBoxStyle.Critical)
End If
End If

Visa signatur

Jag tyckte att denna text räckte fint