Visual Basic - Problema consulta LDAP

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Problema consulta LDAP

Publicado por Jordi (6 intervenciones) el 04/05/2017 09:20:32
Buenas,

Estoy teniendo un problema con un método que se encarga de realizar una conexión LDAP y devolver unos datos.

El error es el siguiente:
1
The search filter cannot be recognized.

Esto se produce en la condición:
1
2
3
4
5
6
if not objRs.EOF then
	objRs.MoveFirst
	GetField_ADUser = objRS.Fields(sFieldAD)
else
	'msgbox sMail
end if

Donde da el fallo en el If.

El método entero es el siguiente

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public function GetField_ADUser(upe, sFieldAD)
	'Set ObjFSOx = CreateObject("Scripting.FileSystemObject")
	'Set myLog = ObjFSOx.OpenTextFile("C:\temp\my.log",  8, true, 0)
	'	myLog.WriteLine sMail
	'myLog.Close
	set conn = createobject("ADODB.Connection")
	Set iAdRootDSE = GetObject("LDAP://RootDSE")
	strDefaultNamingContext = iAdRootDSE.Get("defaultNamingContext")
	Conn.Provider = "ADsDSOObject"
	Conn.Open "ADs Provider"
 
	strQueryDL = "<LDAP://" & strDefaultNamingContext & ">; (&(objectCategory=person)(objectClass=user)(sAMAccountName="& upe & "));CN," & sFieldAD & ",adspath;subtree"
	set objCmd = createobject("ADODB.Command")
	objCmd.ActiveConnection = Conn
	objCmd.Properties("SearchScope") = 2 ' we want to search everything
	objCmd.Properties("Page Size") = 1 ' and we want our records in lots of 1 
 
	objCmd.CommandText = strQueryDL
	Set objRs = objCmd.Execute
 
	if isnull(objRS) then
 
	else
		if not objRs.EOF then
			objRs.MoveFirst
			GetField_ADUser = objRS.Fields(sFieldAD)
		else
			'msgbox sMail
		end if
	end if
 
	objRs.close
	Conn.close
	set objRS = nothing
	set objCmd = nothing
	set Conn = nothing
 
end function

He estado mirando información sobre la conexión de LDAP, pero parece estar correcta. No entiendo el motivo del fallo. ¿Alguien me puede despejar este problema?

Gracias, un saludo
Jordi
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder