/[cvs]/joko/TestArea/vb/ActiveDirectory/vb/03-AdsObjectModify/Ex308.frm
ViewVC logotype

Contents of /joko/TestArea/vb/ActiveDirectory/vb/03-AdsObjectModify/Ex308.frm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jan 23 23:17:26 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 = 60
6 ClientTop = 345
7 ClientWidth = 4680
8 LinkTopic = "Form1"
9 ScaleHeight = 3195
10 ScaleWidth = 4680
11 StartUpPosition = 3 'Windows Default
12 Begin VB.CommandButton Example3
13 Caption = "Example 3"
14 Height = 375
15 Left = 480
16 TabIndex = 4
17 Top = 1200
18 Width = 1695
19 End
20 Begin VB.CommandButton Example2
21 Caption = "Example2"
22 Height = 375
23 Left = 2400
24 TabIndex = 3
25 Top = 720
26 Width = 1695
27 End
28 Begin VB.CommandButton Example4
29 Caption = "Example4"
30 Height = 375
31 Left = 2400
32 TabIndex = 2
33 Top = 1200
34 Width = 1695
35 End
36 Begin VB.CommandButton Example1
37 Caption = "Example 1"
38 Height = 375
39 Left = 480
40 TabIndex = 1
41 Top = 720
42 Width = 1695
43 End
44 Begin VB.Label Label1
45 Caption = "Session 9-308 Examples"
46 BeginProperty Font
47 Name = "MS Sans Serif"
48 Size = 13.5
49 Charset = 0
50 Weight = 700
51 Underline = 0 'False
52 Italic = 0 'False
53 Strikethrough = 0 'False
54 EndProperty
55 Height = 375
56 Left = 600
57 TabIndex = 0
58 Top = 120
59 Width = 3495
60 End
61 End
62 Attribute VB_Name = "Form1"
63 Attribute VB_GlobalNameSpace = False
64 Attribute VB_Creatable = False
65 Attribute VB_PredeclaredId = True
66 Attribute VB_Exposed = False
67 Option Explicit
68
69 Private Sub Example1_Click()
70
71 Dim user As IADsUser
72
73 ' Bind to user object
74 'Set user = OpenObject("LDAP://nt5dc/CN=Joe Smith,OU=Dev,DC=nt5dom,DC=msft,DC=Com")
75 Set user = OpenObject("LDAP://192.168.10.150/cn=testperson,ou=People,o=netfrag.org,c=de")
76
77 user.GetInfo ' Populate the cache
78 'Debug.Print "Current Name: " + user.FirstName
79 Debug.Print "Current Email: " + user.Get("title")
80 ' Change the user's first name
81 'user.FirstName = "Joseph"
82 user.Put "title", "anothertitle"
83 user.SetInfo ' Commit changes to server
84
85 ' Alternative “Generic Get/Put” forms
86 'Debug.Print user.Get("GivenName")
87 'user.Put "GivenName", "Giuseppi"
88
89 End Sub
90
91 Private Sub Example2_Click()
92 Dim MyContainer As IADsContainer
93 Dim MyChildObject As IADsUser
94
95 'Bind to Container Object
96 Set MyContainer = OpenObject("LDAP://nt5dc/OU=dev,DC=nt5dom,DC=msft,DC=com")
97
98 'Create child object in cached container
99 Set MyChildObject = MyContainer.Create("user", "CN=Mary Smith")
100
101 'Set mandatory properties
102 MyChildObject.Put "samAccountName", "MarySmith"
103
104 'Commit object to server
105 MyChildObject.SetInfo
106
107 'Now delete the child object on the server
108 MyContainer.Delete "User", "CN=Mary Smith"
109
110 End Sub
111
112 Private Sub Example3_Click()
113
114 Enumerate ("LDAP://nt5dc/DC=nt5dom,DC=msft,DC=com")
115 Enumerate ("LDAP://192.168.10.1/o=Tunemedia,c=de")
116
117 End Sub
118 Sub Enumerate(strPath As String)
119 Dim MyContainer As IADsContainer
120 Dim MySubContainer As IADsContainer
121 Dim Object As IADs
122
123 On Error Resume Next
124
125 'Bind to container object
126 Set MyContainer = OpenObject(strPath)
127
128 'Enumerate child objects
129 For Each Object In MyContainer
130 Err.Clear
131 Debug.Print Object.adsPath
132 If Err <> 0 Then Exit For
133 Set MyContainer = GetObject(Object.adsPath)
134 If Object.iscontainer Then Enumerate (Object.adsPath)
135 Next Object
136 End Sub
137
138 Private Sub Example4_Click()
139 Dim queryStr As String
140 Dim MyConnection As Object
141 Dim MyRecordset As Object
142 Dim szUserDN As String
143 Dim szUserPassword As String
144
145 szUserDN = "CN=Administrator,cn=users,DC=nt5dom,DC=msft,DC=com"
146 'szUserDN = "Administrator@nt5dom.msft.com"
147 'szUserDN = "nt5dom\administrator"
148 szUserPassword = ""
149
150 queryStr = "<LDAP://nt5dc/DC=nt5dom,DC=msft,DC=com>;(sn=Smith); givenname,sn,adspath;subtree"
151 Set MyConnection = CreateObject("ADODB.Connection")
152 MyConnection.Provider = "ADsDSOObject"
153 MyConnection.Open "Active Directory Provider", szUserDN, szUserPassword
154 Set MyRecordset = MyConnection.Execute(queryStr)
155 Dim user As IADsUser
156 While Not MyRecordset.EOF
157 Debug.Print "User: " + _
158 CStr(MyRecordset.Fields(0)) + " " + _
159 CStr(MyRecordset.Fields(1))
160 Set user = OpenObject(MyRecordset.Fields(2))
161 user.SetPassword "abc"
162 MyRecordset.MoveNext
163 Wend
164
165 End Sub

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