how to sort out 'active directory cannot be found in cache' error

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 7
Reputation: Gunapriya is an unknown quantity at this point 
Solved Threads: 0
Gunapriya Gunapriya is offline Offline
Newbie Poster

how to sort out 'active directory cannot be found in cache' error

 
0
  #1
Jul 4th, 2005
Hi All,

I want to update an attribute in LDAP using VB. when i try to do this using the obj.get property I get the message: 'The active directory property cannot be found in the cache'. How to sort out this error'

Thanks for any help
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: how to sort out 'active directory cannot be found in cache' error

 
0
  #2
Jul 7th, 2005
It would seem to me that you are looking for a property that doesn't exist in LDAP. Have you checked the name of the property? Post the code, and I can look through it.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 514
Reputation: techniner is an unknown quantity at this point 
Solved Threads: 19
techniner techniner is offline Offline
Posting Pro

Re: how to sort out 'active directory cannot be found in cache' error

 
0
  #3
Jul 7th, 2005
Compare your code to this or simply use this code as a starting point.


Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2.  
  3.  
  4. Public Enum Enum_adscAccessType
  5. adscDenyedAccess = 0
  6. adscDataReader = 1
  7. adscDataWriter = 2
  8. End Enum
  9.  
  10.  
  11. Public Function AllowAccess(LoginID As String, Group As String) As Boolean
  12.  
  13. Dim oCN As ADODB.Connection, oCM As ADODB.Command, oRS As ADODB.Recordset, oField As ADODB.Field
  14. Dim oUser As IADs, oParent As IADs, oGroup As IADs
  15. Dim oPropList As IADsPropertyList, oPropEntry As IADsPropertyEntry, oPropVal As IADsPropertyValue
  16. Dim sPath As String, v As Variant, i As Variant
  17. 'This function checks a specific users r
  18. ' ights via their login and what ever grou
  19. ' p you pass in.
  20. 'You will need to replace the {YOUR DC H
  21. ' ERE} with your own domain controller to
  22. ' active directory.
  23. Set oCN = New ADODB.Connection
  24. Set oCM = New ADODB.Command
  25. Set oRS = New ADODB.Recordset
  26. oCN.Provider = "ADsDSOObject"
  27. oCN.Open
  28. Set oCM.ActiveConnection = oCN
  29. oCM.CommandText = "SELECT AdsPath FROM 'LDAP://OU=Branches,OU=Corp,DC={YOUR DC HERE},DC=com' " & _
  30. "WHERE objectCategory='person' AND cn='" & LoginID & "'"
  31.  
  32. oCM.Properties("searchscope") = 2
  33. Set oRS = oCM.Execute
  34.  
  35.  
  36. If Not oRS.EOF Then
  37. Set oUser = GetObject(oRS("AdsPath").Value)
  38. oUser.GetInfo
  39. Set oParent = GetObject(oUser.Parent)
  40. Set oParent = GetObject(oParent.Parent)
  41.  
  42.  
  43. For i = 0 To oUser.PropertyCount - 1
  44. Set oPropEntry = oUser.Item(i)
  45.  
  46.  
  47. If oPropEntry.Name = "memberOf" Then
  48.  
  49. For Each v In oPropEntry.Values
  50. Set oPropVal = v
  51. sPath = oPropVal.DNString
  52. Set oGroup = GetObject("LDAP://" & sPath)
  53.  
  54.  
  55. If oGroup.Name = "CN=" & Group Then
  56. AllowAccess = True
  57. Goto ShutDown
  58. End If
  59.  
  60. Set oGroup = Nothing
  61. Next
  62.  
  63. End If
  64.  
  65. oUser.Next
  66. Next
  67.  
  68. End If
  69.  
  70. AllowAccess = False
  71. ShutDown:
  72. Set oCN = Nothing
  73. Set oRS = Nothing
  74. Set oCM = Nothing
  75. Set oField = Nothing
  76. Set oUser = Nothing
  77. Set oParent = Nothing
  78. Set oGroup = Nothing
  79. Set oPropList = Nothing
  80. Set oPropEntry = Nothing
  81. Set oPropVal = Nothing
  82. Set v = Nothing
  83. End Function
  84.  
  85.  
  86. Public Function ADSCAllowAccessByGroup(Group As String, UserName As String) As Boolean
  87.  
  88. On Error Resume Next
  89. Dim oGroup As ActiveDs.IADsGroup
  90. Dim oUser As ActiveDs.IADsUser
  91. 'This function checks whether or not a u
  92. ' ser is in a specific group. It will retu
  93. ' rn a true or false
  94. 'You will need to replace the {YOUR DC H
  95. ' ERE} with your own domain controller to
  96. ' active directory.
  97. Set oGroup = GetObject("WinNT://{YOUR DC HERE}.com/" & Group)
  98.  
  99.  
  100. If oGroup Is Nothing Then
  101. ADSCAllowAccessByGroup = False
  102. Exit Function
  103. End If
  104.  
  105.  
  106. For Each oUser In oGroup.Members
  107. Debug.Print oUser.Name
  108.  
  109.  
  110. If UCase(oUser.Name) = UCase(UserName) Then
  111. ADSCAllowAccessByGroup = True
  112. Exit Function
  113. End If
  114.  
  115. Next
  116.  
  117. ADSCAllowAccessByGroup = False
  118. End Function
  119.  
  120.  
  121. Public Function ADSCAllowAccessByUser(UserName As String, Group As String) As Boolean
  122.  
  123. On Error Resume Next
  124. Dim oGroup As ActiveDs.IADsGroup
  125. Dim oUser As ActiveDs.IADsUser
  126. Set oUser = GetObject("WinNT://{YOUR DC HERE}.com/" & UCase(UserName) & ",user")
  127.  
  128.  
  129. If oUser Is Nothing Then
  130. ADSCAllowAccessByUser = False
  131. Exit Function
  132. End If
  133.  
  134.  
  135. For Each oGroup In oUser.Groups
  136.  
  137.  
  138. If UCase(oGroup.Name) = UCase(Group) Then
  139. ADSCAllowAccessByUser = True
  140. Exit Function
  141. End If
  142.  
  143. Next
  144.  
  145. End Function
  146.  
  147.  
  148. Public Function ADSCAccessType(Location As String, UserName As String, Module As String, AppName As String) As Enum_adscAccessType
  149.  
  150. On Error Resume Next
  151. Dim oGroup As ActiveDs.IADsGroup
  152. Dim oUser As ActiveDs.IADsUser
  153. 'This function assumes that you already
  154. ' have 2 types of groups set up. One that
  155. ' has DataReader at the end and another
  156. 'that has datawriter at the end. It also
  157. ' assumes that you have set up your group
  158. ' name in the following
  159. 'order: Location_AppName & Module & Data
  160. ' Reader/DataWriter.
  161. 'You can change this to fit your needs.
  162. ' The main part is the first line of code
  163. ' that sets the oUser
  164. 'You will need to replace the {YOUR DC H
  165. ' ERE} with your own domain controller to
  166. ' active directory.
  167. Set oUser = GetObject("WinNT://{YOUR DC HERE}.com/" & UCase(UserName) & ",user")
  168.  
  169.  
  170. If oUser Is Nothing Then
  171. ADSCAccessType = adscDenyedAccess
  172. Exit Function
  173. End If
  174.  
  175.  
  176. For Each oGroup In oUser.Groups
  177.  
  178.  
  179. Select Case oGroup.Name
  180. Case Location & "_" & AppName & Module & "DataReader"
  181. ADSCAccessType = adscDataReader
  182. Exit Function
  183. Case Location & "_" & AppName & Module & "DataWriter"
  184. ADSCAccessType = adscDataWriter
  185. Exit Function
  186. End Select
  187.  
  188. Next
  189.  
  190. ADSCAccessType = adscDenyedAccess
  191. End Function
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 13518 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC