VBS GetObject("LDAP://RootDSE")

VBS GetObject("LDAP://RootDSE")

Postby Biel EA6DD » Fri Mar 14, 2008 4: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/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby Antonio Linares » Sat Mar 15, 2008 3:21 pm

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);
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Biel EA6DD » Mon Mar 17, 2008 8:17 am

Thanks Antonio, I will take a look.
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

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

Postby Gale FORd » Wed Oct 13, 2010 3:56 pm

Did you get this to work? I am trying to get this to work also.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

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

Postby Carles » Fri Oct 15, 2010 12:38 pm

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 ;-)
Salutacions, saludos, regards

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

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1090
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

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

Postby joaosolution » Thu Feb 19, 2015 4: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
joaosolution
 
Posts: 4
Joined: Wed Oct 10, 2012 4:43 pm

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

Postby karinha » Thu Feb 19, 2015 7:13 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

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

Postby joaosolution » Thu Feb 19, 2015 7: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
joaosolution
 
Posts: 4
Joined: Wed Oct 10, 2012 4:43 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Rick Lipkin and 94 guests