Re: Active Directory help



Hi Bruce,

Thanks for the tip on Synapse. I am using it for FTP but will check it for LDAP.

Andy

"Bruce Michener" <bmichene@xxxxxxxxxx> wrote in message news:47ff7571$1@xxxxxxxxxxxxxxxxxxxxxxxxx
The Synapse library supports LDAP protocol. I've used it to read and update our ActiveDirectory. http://synapse.ararat.cz

Andy wrote:
I have to add this code snippet to my application but it is in VB.
How do I translate so that I can make it work in Delphi?

Thanks very much in advance.

Andy

Private Function ADLogin(Username As String, Password As String) As String
Dim dso As IADsOpenDSObject
Dim iadRootDSA As IADs
Const FUNC_NAME As String = "ADLogin"

Const ADS_SECURE_AUTHENTICATION As Integer = 1
'- Hitting a network resource - turn on generic error handling
On Error GoTo ERR_HANDLER
'- Create an Active Directory Service Interface which interacts with AD through LDAP
Set dso = GetObject("LDAP:")
'- Encrypts and authenticates the username and pwd against Active Directory -
Set iadRootDSA = dso.OpenDSObject("LDAP://rootDSE";, Username, Password, ADS_SECURE_AUTHENTICATION)
'- Not expecting anymore errors - turn off generic error handling
On Error GoTo 0
'Debug.Print iadRootDSA.AdsPath ' <- Used for debugging purposes
If Not iadRootDSA Is Nothing Then
If Password = "" Then
ADLogin = "Invalid Username or Password"
Else
ADLogin = "AD Login Complete"
End If
Else
ADLogin = "Active Directory Error"
End If
GoTo EndCleanup

ERR_HANDLER:
Dim ErrorDesc As String
If Not Err Is Nothing Then
If Err.Number <> 0 Then
Select Case Err.Number
Case -2147023570
ErrorDesc = "Invalid Username or Password."
Case Else
ErrorDesc = "Active Directory Error"
End Select
ADLogin = ErrorDesc
App.LogEvent Format$(Now, "YYMMDD HH:MM:SS") & " Error Number: " & Err.Number & " Description: " & Err.Description & _
" Source: cBSCPrincipal.ADLogin"
End If
End If
EndCleanup:
'-- House Cleaning --
m_LoginComplete = True
If Not dso Is Nothing Then Set dso = Nothing
If Not iadRootDSA Is Nothing Then Set iadRootDSA = Nothing

End Function

.



Relevant Pages

  • Re: Active Directory help
    ... I've used it to read and update our ActiveDirectory. ... '- Create an Active Directory Service Interface which interacts with AD through LDAP ... ADLogin = "Invalid Username or Password" ... ErrorDesc = "Invalid Username or Password." ...
    (borland.public.delphi.thirdpartytools.general)
  • JNDI + LDAP + Active Directory + ObjectChangeListener
    ... The documentation I have been able to find says that ActiveDirectory ... Authentication/Auditing server with Active Directory and other LDAP ... The Authentication app in "native" mode maintains its own user datbase ... logged through the Authentication server. ...
    (comp.lang.java.help)
  • JNDI + LDAP + Active Directory + ObjectChangeListener
    ... The documentation I have been able to find says that ActiveDirectory ... Authentication/Auditing server with Active Directory and other LDAP ... The Authentication app in "native" mode maintains its own user datbase ... logged through the Authentication server. ...
    (microsoft.public.win2000.active_directory)
  • JNDI + LDAP + Active Directory + ObjectChangeListener
    ... The documentation I have been able to find says that ActiveDirectory ... Authentication/Auditing server with Active Directory and other LDAP ... The Authentication app in "native" mode maintains its own user datbase ... logged through the Authentication server. ...
    (microsoft.public.windows.server.active_directory)
  • JNDI + LDAP + Active Directory + ObjectChangeListener
    ... The documentation I have been able to find says that ActiveDirectory ... Authentication/Auditing server with Active Directory and other LDAP ... The Authentication app in "native" mode maintains its own user datbase ... logged through the Authentication server. ...
    (comp.lang.java.programmer)