CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Active Directory Solution

Print topic Send  topic

Author Message
pkrawetz

Posts: 77
Posted: 02/12/2009, 9:08 AM

In case you are looking for access to active directory or LDAP below is a solution which works. You would need to taylor it to your organizational standards.

<%
Dim strDomain
Dim strPassword

strDomain = "xyz"
strUserID = "abcdefg"
strPassword = "12345678"

' Open a Connection object.
Set con = CreateObject("ADODB.Connection")
Set com = CreateObject("ADODB.Command")
con.Provider = "ADsDSOObject"
con.Properties("ADSI Flag") = 1
con.Properties("User ID") = strDomain + "\" + strUserID
con.Properties("Password") = strPassword

con.Open "Active Directory Provider"

' Create a command object on this connection.
Set Com.ActiveConnection = con
Com.Properties("searchscope") = ADS_SCOPE_SUBTREE 'Define in ADS_SCOPEENUM
Com.Properties("Cache Results") = False ' do not cache the result, it results in less memory requirements

' Set the query string.
Com.CommandText = "select memberof from 'LDAP://adldap.com/ou=internal, dc=uvw, dc=xyz, dc=com' where objectClass='User' and objectCategory='person' and samaccountname='some_account' "

' Set search preferences.
Set Com.ActiveConnection = con
Com.Properties("Page Size") = 1000
Com.Properties("Timeout") = 30 'seconds

' Execute the query.
Set rs = Com.Execute

if rs.BOF = FALSE then
UserGroups = rs.Fields("memberof").value
end if

' Navigate the record set.
InGroup = 0
for each Grp in UserGroups
newgroup=split(Grp,"=")
newgroup2=left(newgroup(1), len(newgroup(1))-3)
' response.write newgroup2 & "<br>"
if newgroup2 = "some_group" then
InGroup = 1
end if
if newgroup2 = "some_group2" then
InMgrGroup = 1
end if
next

Set con = nothing
Set com = nothing
%>
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.