|
I can't find the other thread, so I'm gonna post this here.
Here's what I've done to populate my forum groups based on my Active Directory groups:
in functions_windows_authentication.asp i changed the code that says:
'We need to get the start user group ID from the database 'Initalise the strSQL variable with an SQL statement to query the database 'strSQL = "SELECT " & strDbTable & "Group.Group_ID " & _ '"FROM " & strDbTable & "Group" & strDBNoLock & " " & _ '"WHERE " & strDbTable & "Group.Starting_group = " & strDBTrue & ";"
to
dim ADS_SCOPE_SUBTREE dim objConnection dim objCommand dim objRecordSet dim distName dim arrMemberOf dim theGroup dim objUser dim theGroupList dim intPrimaryGroupID ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.CommandText = "Select distinguishedName, primaryGroupToken from 'LDAP://DC=my,DC=domain' where sAMAccountName=' " & strUserName & "'" objCommand.Properties("Page Size") = 100 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute If objRecordSet.RecordCount > 0 Then objRecordSet.MoveFirst distName = vbNullString distName = objRecordSet.Fields("distinguishedName").Value else 'user not found in AD End If
if distName <> vbnullstring then 'lookup all groups but primary Set objUser = GetObject("LDAP://" & distname) arrMemberOf = objUser.GetEx("memberOf") intPrimaryGroupID = objUser.Get("primaryGroupID")
For Each theGroup in arrMemberOf theGroupList = theGroupList & lcase(theGroup) & "," Next
'look up primary group objCommand.CommandText = "< - ;(objectCategory=Group);distinguishedName,primaryGroupToken;subtree - ;(objectCategory=Group);distinguishedName,primaryGroupToken;subtree">LDAP://DC=my,DC=domain>;(objectCategory=Group);distinguishedName,primaryGroupToken;subtree " Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordset.EOF If objRecordset.Fields("primaryGroupToken") = intPrimaryGroupID Then theGroupList = theGroupList & lcase(objRecordSet.Fields("distinguishedName").Value) & "," End If objRecordset.MoveNext Loop
'look for specific groups: 'enterprise admins = db admins '_faculty = moderators 'everyone else = newbies if instr(theGroupList,"enterprise admins,") <> 0 then 'admin 'We need to get the start user group ID from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Group.Group_ID " & _ "FROM " & strDbTable & "Group" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Group.Name = 'Admin Group';" elseif instr(theGroupList,"_faculty,") <> 0 then 'moderators 'We need to get the start user group ID from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Group.Group_ID " & _ "FROM " & strDbTable & "Group" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Group.Name = 'Moderator Group';" else 'newbies 'We need to get the start user group ID from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Group.Group_ID " & _ "FROM " & strDbTable & "Group" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Group.Starting_group = " & strDBTrue & ";" end if else 'newbies 'We need to get the start user group ID from the database 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT " & strDbTable & "Group.Group_ID " & _ "FROM " & strDbTable & "Group" & strDBNoLock & " " & _ "WHERE " & strDbTable & "Group.Starting_group = " & strDBTrue & ";" end if
|