In the following code strUser gets set correctly on line 3.
However user returns a value of Nothing after line 4 executes.
Dim strUser As String
Dim user As MembershipUser
strUser = gvUsers.SelectedRow.Cells(0).Text
user = Membership.GetUser(strUser)
This code is being used to change the password of another user.
I can find lots of references to code which is for the logged in user but nothing else.
Anyone got any ideas.
Many thanks
Amanda
Worked it out. The UserName and the LoweredUserName were out of sync thus Membership.GetUser could not find the user based on UserName even though it existed.
Related
So I have a program that I have three groups of users, and I am storing user names, permission levels, usernames and passwords in a veryhidden/protected sheet. (Yes I know this is not particularly secure but it is not to prevent malintent it simply will avoid people stumbling upon things they shouldnt. Nobody is going to be able to uncover very hidden sheets or get into the code.)
The function below is what I have been using. The for each loop is going into the users sheet and finding the username, but for some reason it says that the password is wrong no matter what. I do not know a ton about string comparison and I suspect that one of my conversions or the way I am comparing the passwords is not doing it's job. I have tweaked this a bunch of different ways, but I am missing something basic I think.
Function getSecurityLevel(user As String, pw As String) As Single
Dim userNames As Range
Dim thisUser As Range
Dim uName
Dim userWS As Worksheet
Set userWS = Worksheets("Users")
Application.ScreenUpdating = False
Module4.unprotectUsers
Set userNames = userWS.ListObjects("userTable").ListColumns(3).DataBodyRange
For Each thisUser In userNames
If LCase(CStr(thisUser.Text)) = LCase(user) Then
uName = thisUser.Address
Range(uName).Offset(0, 1).Select
If CStr(ActiveCell.Text) <> pw Then
MsgBox "Your password is incorrect", vbOKOnly
Exit For
Else
ActiveCell.Offset(0, 1).Select
getSecurityLevel = ActiveCell.Value
Exit For
End If
End If
Next thisUser
Module4.hideAll
Application.ScreenUpdating = True
MsgBox "Your username could not be found, please try again", vbOKOnly
End Function
I just need it to properly compare the input password from the userform to the cell next to the matching username, then offset one more and read the security level
This isn't the answer you want but you need to know this.
"Nobody is going to be able to uncover very hidden sheets or get into the code." That is a bold statement and also very untrue.
Setting aside the fact that password protection offered by the VB editor is easily broken.
Anyone with access to the file can change the extension to ZIP. From there, everyone's password is visible as plain text in xl\sharedstrings.xml and your vaunted very hidden worksheet is plainly visible in the file structure and can be unhidden by removing state="veryHidden" in xl\workbook.xml then rezipping and replacing ZIP with the appropriate Excel extension.
Do your users a favor. If you're not going to encrypt passwords and insist on storing them as plain text - then at the very least, do not save them in a file that is distributed to all of your users.
What happens if that file is sent to someone outside the organization or if anyone in your company caught whiff of you sending unencrypted passwords to your users... Think man! This is not the way forward!!!
I have a login system that works well, using XML files to store logins, and then I can read the users and passwords, see if it matches, if it does, move to the next form, if it doesn't, error message.
However, when the form switches over, I want to be able to display the username in the to left corner, so the user knows who they are displayed as. But I don't know how to memorise the specific user that logged in on the previous form onto the new form now?
I tried making a "public variable" (sort of hard to do for me, not sure if i even did it right), which will read the textbok that the user inputs their name in if the username was correct, and gets dipaslayed for the next form. I don't thin the public vairable worked very well.
If BlnUserFound = True Then
'ActiveUser is the "public vairable"
ActiveUser = tbxUser.Text
'Open the main screen
Me.Hide()
Home.Show()
Else
MessageBox.Show("User Details Not found" & vbCrLf _
& "Please Try Again", "Login Error")
End If
What am I doing wrong?!
Just simply connect it to another new variable name and use it in form 2 e.g
dim ActiveUser2 as string
ActiveUser2 = Form1.ActiveUser then just simply easiest way would be have a label or something on your form, set it to not visible and then just apply ActiveUser2.text to the Label.Text
Using the CreateObject("msxml2.xmlhttp") to extract information from a web-page, I've discovered that null response from getElementsByTagName("table") is experienced when a login is required on said web-page.
I've attempted to overcome this by using the following to set username/password for the login page:
oDom.getElementById("login-form-username").Value = strUser
oDom.getElementById("login-form-password").Value = strPwd
I've subsequently attempted to submit the information using:
oDom.getElementById("login-form-submit").Click
Unfortunately, the .Click does not seem to work. Is there anything else required to in order to submit the information? The strUser and strPwd values are input from InputBox.
Many thanks in advance
G
My task is, when opening a database in Lotus Notes, the current user will be ask to input his/her password that was given by his superior. Is there a way how to do that? Just a simple prompt or form that will ask for your password before viewing the database.
Please understand that I do not intend this answer to be disrespectful, but this is really not a task for a beginner at Notes and Domino, as you have stated that you are. You should tell that to your boss. This is a task for someone who has deep understanding of the principles of security and of the mechanisms Notes and Domino provide for it. If you do not understand my comments on #Thomas Adrian's answer, then that applies to you. Again, no disrespect intended.
As security guru Bruce Schneier said, "if you ask amateurs to act as front-line security personnel, you shouldn't be surprised when you get amateur security".
Yes you can put code in queryopendatabase which is located in database script.
Create a button for your superior to store the password in a general profile document within the database
2 when users open the database use the queryopendatabase script to present a password prompt. You can use inputbox in lotus script. Verify the password against the profile document. If a wrong password is entered close the database.
You can use the following code as an embryo, This code use a "real" document but you can easily modify this to be a profile document.
Remember when you test this to close Domino Designer as the NSF is cached as long as DDE is open
Sub Postopen(Source As Notesuidatabase)
Dim db As NotesDatabase
Set db = source.Database
Dim d As NotesDocument, flag As Integer, upw As String, pw As String
upw = InputBox("Enter Password")
Set d = db.getView("Main").getFirstDocument()
If Not d Is Nothing Then
pw = d.password(0)
If pw = upw Then
flag = 1
End If
End If
If flag <> 1 Then Call source.Close()
End Sub
Done quite a bit of looking but not finding what i need. From a win form i'd like to open up a web browser passing in a url. But i need to provide authentication while doing this. I tried just using a system.diagnostics.process.start("http://userid:pw#site") but that does not work. Was hoping someone could lend a hand.
thanks
shannon
Using the tip.. here is what i have...
Dim m As New System.Security.SecureString
Dim pw As String = "mypassword"
For Each c As Char In pw
m.AppendChar(c)
Next
Dim pis As ProcessStartInfo = New ProcessStartInfo("http://test/pagegoingafter.aspx")
With pis
.UserName = "userid"
.Password = m
.UseShellExecute = False
End With
Process.Start(pis)
I'm getting a logon failure: unknown user name or password.
it's seems strange to me.. but if i do in firefox http://userid:mypassword#test/pagegoingafter.aspx i can get to my page. If i do the same thing in IE 8... no joy.
so is there anything else that can be done to get IE to work.. cause i'm thinking that would allow the above code to work as well.
You can provide credentials to the process.
See this overload to Process.Start - it takes a username, password and domain.
There are other alternatives - see this blog post.