therustycook Absent Member.
Absent Member.
2353 views

vbscript to query ldap attributes

I am trying to write a vbscript to access the values in different
attributes in eDirectory using ldap connections. I have been able to
connect to the server and to do a basic query. The problem is that I can
only get to 4 attributes at this point. Not sure why that is. I can see
uid, givenName, sn, and objectClass. We have a number of custom attributes
in the system that I am trying to access. This tree is used exclusively
for ldap queries by some other applications. I need to be able to test and
troubleshoot against it. I would like to do vbscript for a lot of it
because it is quick and easy.

The script that I am using to pull up like uid is:

set objUser =
GetObject("LDAP://dnvnds1.foremost.com/cn=rly00,ou=employees,ou=people,o=foremost")
objUser.GetInfo
WScript.echo objUser.sn
WScript.echo objUser.uid
WScript.echo objUser.givenName

The first field that I am trying to pull up is FicCorpPW. I can pull it up
using ldapsearch from the command line just fine. If I use WScript.echo
objUser.FicCorpPW I get nothing back. Was wondering how best to query this
attribute from vbscript.

Labels (1)
0 Likes
2 Replies
Anonymous_User Absent Member.
Absent Member.

Re: vbscript to query ldap attributes

Sounds like a rights issue. -jim

rusty.yonkers@foremost.com wrote:
> I am trying to write a vbscript to access the values in different
> attributes in eDirectory using ldap connections. I have been able to
> connect to the server and to do a basic query. The problem is that I can
> only get to 4 attributes at this point. Not sure why that is. I can see
> uid, givenName, sn, and objectClass. We have a number of custom attributes
> in the system that I am trying to access. This tree is used exclusively
> for ldap queries by some other applications. I need to be able to test and
> troubleshoot against it. I would like to do vbscript for a lot of it
> because it is quick and easy.
>
> The script that I am using to pull up like uid is:
>
> set objUser =
> GetObject("LDAP://dnvnds1.foremost.com/cn=rly00,ou=employees,ou=people,o=foremost")
> objUser.GetInfo
> WScript.echo objUser.sn
> WScript.echo objUser.uid
> WScript.echo objUser.givenName
>
> The first field that I am trying to pull up is FicCorpPW. I can pull it up
> using ldapsearch from the command line just fine. If I use WScript.echo
> objUser.FicCorpPW I get nothing back. Was wondering how best to query this
> attribute from vbscript.
>

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: vbscript to query ldap attributes


Im able to read elements if in eDirectory my user has the little read
checkmark aside its user privledges...

theres also one for Delete too

but now Im struggling with the syntax for delete.

heres how I read other attributes
' *************************************************
' CONNECTION Block
' *************************************************
''Creating the Connection Object
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
'' Setting the Data Source
objConnection.Open "Active Directory Provider", "ldap,user,name",
"clear_text_password"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://myldapserver/ou=forrest/o=domain>;
(cn=" & strUserToPurge & "); ADsPath,testTARGETAttribute;subtree"

Set objRecordSet = objCommand.Execute
' *************************************************
' Error null handling
' *************************************************
If objRecordSet.EOF Then
strErrorNull = MsgBox("No User is Found", vbOKCancel, "Error")
Else
' *************************************************
' When target User is FOUND
' *************************************************
While Not objRecordset.EOF
userStringFound = objRecordSet.Fields("testTARGETAttribute")
'make a string variable for each attribute you wish to pull for this
object also be sure to denote in command line before subtree
' *************************************************

Wscript.Echo "test attribute returned is: " & userStringFound

' Perform deletion NOT yet working... 😞
objRecordSet.Delete userStringFound ' NOTWORKING :S
objRecordSet.Delete objRecordSet.Fields("testTARGETAttribute")
' NOTWORKING :S

' *************************************************
objRecordset.MoveNext
Wend
End If
' *************************************************
' housekeeping
' *************************************************
objConnection.Close


--
janderson1
------------------------------------------------------------------------
janderson1's Profile: http://forums.novell.com/member.php?userid=118755
View this thread: http://forums.novell.com/showthread.php?t=364992

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.