How To Retrieve Attribute Values of Site Server 3.0 LDAP Users with VBScript (328024)



The information in this article applies to:

  • Microsoft Site Server 3.0

This article was previously published under Q328024

SUMMARY

The Microsoft Visual Basic Scripting Edition (VBScript) code sample in this article retrieves attributes of Site Server 3.0 Lightweight Directory Access Protocol (LDAP) users.

MORE INFORMATION

The code sample assumes that users are in the ou=members container.

The RetrieveMemberAttribute function takes the user name and attribute name to be retrieved and returns the user's attribute values.

Note that you must replace everything that is enclosed in brackets ([]) with the appropriate values for your environment.
<%
Public Function RetrieveMemberAttribute (UserName, AttributeName)
 	
	Dim LDAPtest 	
	Dim ADSObject
	Dim MembersContainer
 	Dim User
 	Dim Item

 	Set LDAPtest = GetObject("LDAP:")
 	Set ADSObject = 

LDAPtest.OpenDSObject("LDAP://[LDAPServerName]:[LDAPPortNumber]/o=[RootName]","cn=Administrator,ou=Members,o=[RootName]", 

"[AdministratorPassword]", 0)
  	 
	Set MembersContainer = ADSObject.GetObject ("organizationalUnit","ou=Members")
 	Set User = MembersContainer.GetObject ("member", "cn="&UserName)
	Item = User.Get(AttributeName)

	RetrieveMemberAttribute=Item

	Set Item = Nothing
	Set User = Nothing
 	Set MembersContainer = Nothing 	
 	Set ADSObject = Nothing
 	Set LDAPtest = Nothing

End Function 

'How to call the function RetrieveMemberAttribute:
Response.Write RetrieveMemberAttribute("TestUserName", "TestAttributeName")

%>

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' Copyright (C) 2002.  Microsoft Corporation.  All rights reserved.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
				

Modification Type:MinorLast Reviewed:7/2/2004
Keywords:kbhowto KB328024