/[cvs]/joko/TestArea/vb/ActiveDirectory/vb/04-AdsContainerExample/Form1.frm
ViewVC logotype

Contents of /joko/TestArea/vb/ActiveDirectory/vb/04-AdsContainerExample/Form1.frm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jan 23 23:17:28 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
+ initial check-in

1 VERSION 5.00
2 Begin VB.Form Form1
3 Caption = "Form1"
4 ClientHeight = 3195
5 ClientLeft = 4920
6 ClientTop = 2910
7 ClientWidth = 4680
8 LinkTopic = "Form1"
9 ScaleHeight = 3195
10 ScaleWidth = 4680
11 Begin VB.CommandButton Command3
12 Caption = "Command3"
13 Height = 435
14 Left = 1110
15 TabIndex = 2
16 Top = 1860
17 Width = 1365
18 End
19 Begin VB.CommandButton Command2
20 Caption = "Command2"
21 Height = 375
22 Left = 480
23 TabIndex = 1
24 Top = 1200
25 Width = 1575
26 End
27 Begin VB.CommandButton Command1
28 Caption = "Command1"
29 Height = 375
30 Left = 600
31 TabIndex = 0
32 Top = 600
33 Width = 1455
34 End
35 End
36 Attribute VB_Name = "Form1"
37 Attribute VB_GlobalNameSpace = False
38 Attribute VB_Creatable = False
39 Attribute VB_PredeclaredId = True
40 Attribute VB_Exposed = False
41 Option Explicit
42
43 Private Sub Command1_Click()
44
45 ' 4. searching - via ADODB
46 Dim adoConn As ADODB.Connection
47 Dim oRecordSet As ADODB.Recordset
48 Dim oField As ADODB.Field
49 Dim objPath As String
50
51
52 Exit Sub
53
54 ' open connection to ldap-server
55 Set adoConn = CreateObject("ADODB.Connection")
56 adoConn.Provider = "ADsDSOObject"
57 'con.Open "Active Directory Provider", "cn=admin,o=santam za", "nomad"
58 adoConn.Open "Active Directory Provider", "", ""
59
60 Set oRecordSet = adoConn.Execute("<LDAP://192.168.10.1/o=Tunemedia,c=de>;(&(objectClass=*));ADsPath;subTree")
61
62 Debug.Print "RecordCount: " & oRecordSet.RecordCount
63
64 ' loop through result-set
65 While Not oRecordSet.EOF
66
67 ' Output each field and value to the debug window
68 For Each oField In oRecordSet.Fields
69 Debug.Print "{" & oField.Name & "}" + " = " + oField.Value
70 Next
71
72 ' get full path to ldap-object ...
73 objPath = oRecordSet.Fields.Item("ADsPath")
74 ' ... and dump it. (FYI: uses "EnumeratePropertyValue" from "ADsHelper" to serialize object)
75 dumpDSObjectByPath objPath
76
77 Debug.Print "-------------------------------------"
78
79 ' next result-entry
80 oRecordSet.MoveNext
81
82 Wend
83
84 ' close result-handle
85 oRecordSet.Close
86
87 ' close connection
88 adoConn.Close
89
90 End Sub
91
92 Function GetDSObject(sDN, sUserName, sPassword)
93 Dim objLDAP
94 Dim obj
95
96 Set objLDAP = GetObject("LDAP:")
97 Set obj = objLDAP.OpenDSObject(sDN, sUserName, sPassword, 0)
98 Set GetDSObject = obj
99 End Function
100
101 Function dumpDSObjectByPath(objPath As String)
102
103 Dim myContainer As IADsContainer
104 Dim myObj As IADs
105
106 Dim myPropertyList As IADsPropertyList
107 Dim myPropertyEntry As PropertyEntry
108 Dim propCount As Long
109 Dim i As Long
110 Dim strValues As String
111
112 Set myPropertyList = GetObject(objPath)
113 myPropertyList.GetInfo 'populate the cache
114 propCount = myPropertyList.PropertyCount
115
116 ' --Loop through each of the properties and output their values ---
117 For i = 0 To propCount - 1
118 strValues = ""
119 Set myPropertyEntry = myPropertyList.Next
120 EnumeratePropertyValue myPropertyEntry, strValues
121 Debug.Print " " & "{" & myPropertyEntry.Name & "}" + " = " + strValues
122 Next
123
124 Set myPropertyList = Nothing
125
126 End Function
127
128 Private Sub Command2_Click()
129
130 Dim o As IADsO
131 Dim ou As IADsOU
132 Dim tmpContainer As IADsContainer
133
134 'Set o = OpenObject("LDAP://192.168.10.150/cn=testperson,ou=People,o=netfrag.org,c=de")
135 Set tmpContainer = OpenObject("LDAP://192.168.10.150/o=netfrag.org,c=de")
136 Set ou = tmpContainer.Create("organizationalUnit", "ou=Addressbooks")
137 ou.Put "ou", "Addressbooks"
138 ou.SetInfo
139
140 End Sub
141
142 Private Sub Command3_Click()
143 FormSetupLdap.Show
144 End Sub

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed