FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour VBS GetObject("LDAP://RootDSE")
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM
VBS GetObject("LDAP://RootDSE")
Posted: Fri Mar 14, 2008 04:17 PM

How I can translate GetObject("LDAP://RootDSE") in (x)harbour code.

Thanks in advance

Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
VBS GetObject("LDAP://RootDSE")
Posted: Sat Mar 15, 2008 03:21 PM
Biel,

Here you have a C++ sample that may help:
http://support.microsoft.com/kb/255042/es

    hr = ADsGetObject(TEXT("LDAP://rootDSE"),
                      IID_IADs,
                      (void**)&pRoot);
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM
VBS GetObject("LDAP://RootDSE")
Posted: Mon Mar 17, 2008 08:17 AM

Thanks Antonio, I will take a look.

Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: VBS GetObject("LDAP://RootDSE")
Posted: Wed Oct 13, 2010 03:56 PM

Did you get this to work? I am trying to get this to work also.

Posts: 1283
Joined: Fri Feb 10, 2006 02:34 PM
Re: VBS GetObject("LDAP://RootDSE")
Posted: Fri Oct 15, 2010 12:38 PM
Hi Biel,

Connection example:

Code (fw): Select all Collapse
#include 'fivewin.ch'
#include "ado.ch"
#include "xBrowse.ch"

STATIC oLdap

*---------------------
FUNCTION ConectaLDAP()
*---------------------
   LOCAL lOk      := .F.
   LOCAL oError

   TRY

     oLdap          := TOleAuto():new("ADODB.Connection")

     oLdap:Provider := 'ADsDSOObject'

     oLdap:Open( "Active Directory Provider" )

     lOk           := .T.

    CATCH oError

      ShowError( oError )

   END

RETU lOk


Example of oRS...

Code (fw): Select all Collapse
...
   TRY

     cString       := "SELECT "                    + ;
                      " displayName,"              + ;
                      " distinguishedName,"        + ;
                      " mail,"                     + ;
                      " telephoneNumber,"          + ;
                      " mobile,"                   + ;
                      " facsimileTelephoneNumber," + ;
                      " otherTelephone,"           + ;
                      " department,"               + ;
                      " sAMAccountname"

     cFrom         := " FROM 'LDAP://teudomini'"   


     cWhere        :=  " WHERE objectCategory   = 'person' AND" + ;
                       "       objectClass      = 'user'   "


     oRs                  := TOleAuto():new("ADODB.RecordSet")

     oRs:ActiveConnection := oLDap


     oRs:Open( cString + cFrom + cWhere, oLDap , 1, 3 )

     xBrowse( oRs )

     oRs:Close()


    CATCH oError

      xBrowse( oError )

   END
...


But u need know a few things. For example, if u need a lot of registers, more than 1000, u need to change page size property, or for example if u want only one level of information or all structure...

Code (fw): Select all Collapse
...
     oCmd                  := TOleAuto():new("ADODB.Command")

     oCmd:ActiveConnection := oLdap


     oCmd:CommandText      := cString + cFrom + cWhere

     oProp                 := oCmd:Properties( 'SearchScope' )
     oProp:value           := ADS_SCOPE_SUBTREE

     oProp                 := oCmd:Properties( 'Page size' )
     oProp:value           := 2000
...


if u need more, don't doubt :-)
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
HIX -> https://github.com/carles9000/hix
Posts: 4
Joined: Wed Oct 10, 2012 04:43 PM
Re: VBS GetObject("LDAP://RootDSE")
Posted: Thu Feb 19, 2015 04:55 PM

Srs.

Gostaria de converter esta função em VbScript para xHarbour, a minha necessidade é validar o usuário pelo Active Directory

Function AuthenticateUser(ByVal strUser, ByVal strPW)
Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_SERVER_BIND = 512

strPath = "LDAP://RootDSE"

Set LDAP = GetObject(strPath)
Set strAuth = LDAP.OpenDSObject(strPath, strUser, strPW, ADS_SECURE_AUTHENTICATION Or ADS_SERVER_BIND)
If Err.Number <> 0 Then
    boolAuth = False
Else
    boolAuth = True
End If
AuthenticateUser = boolAuth

End Function

Agradeço a ajuda

Att
João Bosco

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: VBS GetObject("LDAP://RootDSE")
Posted: Thu Feb 19, 2015 07:13 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 4
Joined: Wed Oct 10, 2012 04:43 PM
Re: VBS GetObject("LDAP://RootDSE")
Posted: Thu Feb 19, 2015 07:25 PM

Karinha

Obrigado pela resposta já havia baixado este código, mas não consigo validar a senha por ele.

Att
João Bosco

Continue the discussion