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
%>
|
|
|
|