|
Solution to what? You haven't shown the code you're using.
|
|
|
|
|
Forgot to post the code, sorry..
|
|
|
|
|
OK, if you're looking to authenticate the credentials provided by the user of your app, it's much simpler to do this:
Imports System.DirectoryServices.AccountManagement
...
Dim isValid As Boolean
Using (pc As PrincipalContext = New PrincipalContext(ContextType.Domain, "YourDomainName"))
isValid = pc.ValidateCredentials("username", "password");
End Using
But, the ^ character is legal in all cases in Active Directory. It doesn't need to be escaped at all.
|
|
|
|
|
Thanks for the reply Dave, your code is simple and great, but it still returns a False value when a caret is on the end of the password.
I forgot to tell - the code is used for a console application. It displays MORE? when I executed it, and I just press ctrl+x to stop the process.
Even if I put four (4) carets, it still returns a False value.
It doesn't produce an error exception, so the code is good..
Can't attach an image here, so I just post a link and see for yourself.
LDAP - Download - 4shared - Uchiha Yueh[^]
But still thanks for the help Dave, I love the simplicity of your code..
|
|
|
|
|
The check will fail if the password is required to be changed or if the password has expired.
Other than that, it's going to be a question for Microsoft.
I don't have an AD setup to test against and there's nothing on the web about the problem of a caret at the end of a password.
Wait, wait, wait. It's been a LONG time, but the caret in a CMD prompt is used by the CMD prompt as an escape character, so it's not really being passed to your code. You can check this by setting a breakpoint on your code to check the credentials and look at the value of 'password' when the breakpoint is hit.
modified 10-Jul-21 11:26am.
|
|
|
|
|
I also don't have an AD setup here at my house.
I'll try it on Wednesday (Phil. Time) at the office and I'll post the result here.
Thanks for your help ^_^
|
|
|
|
|
Dave Kreskowiak wrote: the caret in a CMD prompt is used by the CMD prompt as an escape character But only when typing a command sequence into cmd. Using cin, scanf or similar it is passed direct to the calling application.
|
|
|
|
|
The command line is exactly where he's typing the password, for whatever reason.
|
|
|
|
|
Yes I discovered that after I posted my message to you. But using double quotes round the password fixes it. However, not the best way of doing such an application.
|
|
|
|
|
Agreed. I just told him you would normally never ask for a password on the command line but instead prompt for it after the app launches.
|
|
|
|
|
|
What is the exception that is being thrown? Is that why it is returning false, or is it genuinely the return value?
|
|
|
|
|
The one thing you have not shown us is the actual code that reads the password string.
|
|
|
|
|
Here's the code that Dave has given to me (I changed it a little bit):
Imports System.DirectoryServices.AccountManagement
Module Module1
Sub Main(ByVal args() As String)
Dim isWithAD As Boolean
Try
Dim pc As PrincipalContext = New PrincipalContext(ContextType.Domain, "xx.xx.xx.xx")
Using (pc)
isWithAD = pc.ValidateCredentials(args(0), args(1))
End Using
Console.WriteLine(IIf(isWithAD = True, "Success", "Failed"))
Catch ex As Exception
Console.WriteLine("Error [" + ex.ToString + "] - " + ex.InnerException.ToString)
End Try
End Sub
End Module
The syntax is: CLDAP <username> <password>.
Ex:
CLDAP john_smith 12345
CLDAP "john_smith" "12345"
CLDAP 'john_smith' '12345'
All examples are valid and return a true value. Caret character can be accepted if it is placed in the beginning or in the middle of the password. But, if a caret character is placed at the end of the password, that's where the problem starts 
|
|
|
|
|
You just need to put the password in double quotes:
cldap userid "passwd^"
|
|
|
|
|
Normally, you would never type a password on the command line.
You would prompt for it from the application after it's launched. The application can then accept the password without exposing it, replacing characters on screen with some other character or none at all.
|
|
|
|
|
Hi,
I can find the headertext with
Dim lvg As New LVGROUP()
lvg.cbSize = CUInt(Marshal.SizeOf(lvg))
lvg.mask = LVGF_STATE Or LVGF_GROUPID Or LVGF_HEADER Or LVGF_FOOTER
Dim nRetHeader2 As Integer = SendMessage(m.HWnd, LVM_GETGROUPINFO, nItem, lvg)
Dim sHeadText As String = Marshal.PtrToStringUni(lvg.pszHeader)
Dim sFootTxt As String = Marshal.PtrToStringUni(lvg.pszFooter)
however the foottext is always empty.
same for pszDescriptionTop and pszDescriptionBottom
I set the footer with some code I found on the net
Private Shared Sub SetGrpFooter(ByVal lstvwgrp As ListViewGroup, ByVal footer As String)
If Environment.OSVersion.Version.Major < 6 Then Return
If lstvwgrp Is Nothing OrElse lstvwgrp.ListView Is Nothing Then Return
If lstvwgrp.ListView.InvokeRequired Then
lstvwgrp.ListView.Invoke(New CallbackSetGroupString(AddressOf SetGrpFooter), lstvwgrp, footer)
Else
Dim GrpId As System.Nullable(Of Integer) = GetGroupID(lstvwgrp)
Dim group As New LVGROUP
group.CbSize = Marshal.SizeOf(group)
If (footer = String.Empty) Then
group.PszFooter = Nothing
Else
group.PszFooter = footer
End If
'lstvwgrp.HeaderAlignment = HorizontalAlignment.Center
'group.pszDescriptionBottom = "bottom" & Chr(0)
'group.pszDescriptionTop = "top"
<pre>
group.mask = ListViewGroupMask.Footer + ListViewGroupMask.DescriptionBottom + ListViewGroupMask.DescriptionTop
Dim ip As IntPtr = Marshal.AllocHGlobal(group.cbSize)
Marshal.StructureToPtr(group, ip, False)
If GrpId IsNot Nothing Then
group.IGroupId = GrpId.Value
SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, GrpId.Value, ip)
Else
group.iGroupId = GrpId
SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, GrpId.Value, ip)
End If
End If
End Sub</pre>
I also can't find the rectangles of where I have to draw the texts
What do I do wrong?
Jan
|
|
|
|
|
Where are the programmers geniusses from before?
|
|
|
|
|
JR212 wrote: Where are the programmers geniusses from before? Same place they always are. What is your problem?
|
|
|
|
|
Still the same as described in this topic. I need to find out what the footertext is in a listviewgroup in a .dotnet4 program throu user32.dll sendmessage.
Header is no problem but footer alway return 'nothing'
Jan
modified 18-Jun-21 5:30am.
|
|
|
|
|
|
Hi
Sorry but your first link is for the listviewfooter and not listviewGROUPfouter. I gues I need ListView_GetGroupInfo macro (commctrl.h) - Win32 apps | Microsoft Docs but I cant get that to work.
Your question why not use the default control. I do (partely)! I need to work with ownerdraw and the Listview control in dotnet doesn't have support for the groupfooter or the description(top nor bottom). If using dot core 5.0 I can but I need to work with 4.7 or less.
I'm been looking for weeks and can't find a working example for the groupfooter. I can if it is normaldraw so I have a code to set the footer but not to get/retrieve it.
Jan
|
|
|
|
|
|
your absolutly 100% right. But I can't get it to work
modified 24-Jun-21 2:19am.
|
|
|
|
|
JR212 wrote: But I can get it to work Well I am afraid that no one here has any chance of guessing what that means.
|
|
|
|