active directory scripting using vb - TechRepublic
Question
April 11, 2008 at 11:47 AM
don450p

active directory scripting using vb

by don450p . Updated 18 years, 1 month ago

I have a need to change the description field of several active directory groups in a particalar ou. This is what I was able to come up with, but I am unable to test it.

Const ADS_PROPERTY_UPDATE = 2
Dim reader As StreamReader = _
New StreamReader(winDir & “\group_names.txt”)
Try
Me.ListBox1.Items.Clear()
Do
group_name = Me.ListBox1.Items.Add(reader.ReadLine)

Set objGroup = GetObject _
(“LDAP://cn=group_name,ou=R&D,dc=NA,dc=fabrikam,dc=com”)

objGroup.PutEx ADS_PROPERTY_UPDATE, _
“description”, Array(“what you want it to say here”)
objGroup.SetInfo

Loop Until reader.Peek = -1

Catch
Me.ListBox1.Items.Add(“File is empty”)

Finally
reader.Close()
End Try

Can anyone tell me if this would work? I have worked with visual basic. I took this code from these two sources and put them together
http://support.microsoft.com/kb/304427
http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true

This discussion is locked

All Comments