Page 1 of 1

VBS GetObject("LDAP://RootDSE")

PostPosted: Fri Mar 14, 2008 4:17 pm
by Biel EA6DD
How I can translate GetObject("LDAP://RootDSE") in (x)harbour code.

Thanks in advance

PostPosted: Sat Mar 15, 2008 3:21 pm
by Antonio Linares
Biel,

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

Code: Select all  Expand view
    hr = ADsGetObject(TEXT("LDAP://rootDSE"),
                      IID_IADs,
                      (void**)&pRoot);

PostPosted: Mon Mar 17, 2008 8:17 am
by Biel EA6DD
Thanks Antonio, I will take a look.

Re: VBS GetObject("LDAP://RootDSE")

PostPosted: Wed Oct 13, 2010 3:56 pm
by Gale FORd
Did you get this to work? I am trying to get this to work also.

Re: VBS GetObject("LDAP://RootDSE")

PostPosted: Fri Oct 15, 2010 12:38 pm
by Carles
Hi Biel,

Connection example:

Code: Select all  Expand view
#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: Select all  Expand view
...
   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: Select all  Expand view
...
     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 ;-)

Re: VBS GetObject("LDAP://RootDSE")

PostPosted: Thu Feb 19, 2015 4:55 pm
by joaosolution
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

Re: VBS GetObject("LDAP://RootDSE")

PostPosted: Thu Feb 19, 2015 7:13 pm
by karinha

Re: VBS GetObject("LDAP://RootDSE")

PostPosted: Thu Feb 19, 2015 7:25 pm
by joaosolution
Karinha

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

Att
João Bosco