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 and ASP?

Status
Not open for further replies.

mehere64

Programmer
Jul 6, 2004
3
0
0
US
I am in the process of setting up a company intranet and will be using windows authentication (anonymous access turned off). After grabbing the user's logon info I will then need to check group permissions in order to give them access to certain pages within the website. Other than the code I have listed below (which takes some time to run), that loops through the groups for that user and compares to the group I am passing to it. There may be times that I will have to check for several groups, thereby increasing the amount of time to compute the comparison.

------------------------------------------------------

function checkGroupPermission(strUser, strGroup)
thisUser = strUser
set myDomain = GetObject("WinNT://DOMAINNAME")
myDomain.Filter = Array("group")
for each group in myDomain
strGroupName = group.name
set grp = getObject("WinNT://DOMAINNAME/" & strGroupName)
if grp.isMember("WinNT://DOMAINNAME/" & thisUser) then
if LCase(strGroupName) = LCase(strGroup) then
checkGroupPermission = true
end if
end if
set grp = nothing
next
end function

----------------------------------------------------------

Is there a quicker way to do this? We're not talking minutes in time, but several noticable seconds do elapse.

Thank you for any help you can provide.
 
This code runs real fast for me...

Code:
Function ConfirmMail(LastName)
Dim conn
Dim rs
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.Provider = "ADSDSOObject"
 
conn.Open "Active Directory Provider","DC=domain,CN=user","pass"
Set rs = conn.Execute("<LDAP://yourLDAPServer>;(&(objectClass=organizationalPerson)(sn="&LastName&"));Mail,givenName,sn,Extension-Attribute-1;subtree")
 
conFirmMail = rs.getRows
 
End Function

Dim try
try = ConfirmMail("LastName")
For cnum = 0 To UBound(try,2) 
 response.write try(1, cnum) & " " & try(2, cnum) & " " & try(3, cnum) &  "<BR>"
Next

Just swap in whatever fields you need..

Use your resources, you're on the internet!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top