Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory search using ASP

Status
Not open for further replies.

ACuba10

Programmer
Jul 25, 2006
14
US
I did the call to Active Directory and have the code in VB:
Code:
Dim ent As New System.DirectoryServices.DirectoryEntry("LDAP://dc=RYANBECK,dc=com")

Dim child As System.DirectoryServices.DirectoryEntry

Dim results As System.DirectoryServices.SearchResultCollection

Dim entsearch As New System.DirectoryServices.DirectorySearcher(ent)

Dim search As System.DirectoryServices.SearchResult

entsearch.Filter = ("SAMAccountName=" & p_cID)

'entsearch.Filter = ("cn=" & p_cID)

entsearch.SearchScope = SearchScope.Subtree

results = entsearch.FindAll

Dim ssn As String

Dim name As String

For Each search In results

'ssn = search.Properties("employeeid")(0)

name = search.Properties("Name")(0)

Next

 

Return name
>> What i would like to know is how to translate it into simple ASP so that i can pass two values to another page but i can handle that part of the code - just translation is all i need.
 
yeah i know that but i dont have an option. It must be done in classic ASP. I dont know what the syntax would look like in ASP
 
Thankyou but neither one truly helps. They're not doing what im trying to do. Thankyou anyway
 
I have a script that I cribbed from another TT'er that may be of some benefit. You can modify it as needed, and credit should go to markdmac (as noted in the code below). Let us know if you have additional questions or issues.
Code:
'==========================================================================
'
' NAME: LogonScript.vbs
'
' AUTHOR:  Mark D. MacLachlan, The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 4/10/2003
'
' COMMENT: Enumerates current users' group memberships in given domain.
'
'==========================================================================
ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path, strMember, GroupObj


Set WSHShell = server.CreateObject("WScript.Shell")
Set WSHNetwork = server.CreateObject("WScript.Network")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

'Grab the user name
UserString = WSHNetwork.UserName

'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
	'Test for "[myUserGroup]" group.  If member, then complete page.  If not, then error message.
	if GroupObj.Name = "[myUserGroup]" then
		strMember = "CRE"
		exit for
	else
		strMember = "Non-CRE"
	end if
Next
	
'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHShell = Nothing
Set WSHPrinters = Nothing
'Quit the Script
wscript.quit 

'If not a CRE member, this will present an error message and redirect them to the Real Estate home page.
if strMember = "Non-CRE" then
	Response.Write "This page is for Real Estate personnel only.  <br>" & _
		"Please click <a href=[mySite]'>here</a> to " & _
		"return to the Real Estate home page."
	Response.Flush
	Response.End
end if

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top