Tim Golden wrote:
Dirk Hagemann wrote:
>Hi!
Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentation or some code?
I freely admit I don't do too much changing of AD objects,
but my module should at least support the methods for doing
things. Some examples in Active Directory Cookbook:
http://techtasks.com/code/viewbook/2
Sorry, you wanted to remove a user *from a group*. Misread.
Translated from
http://techtasks.com/code/viewbookcode/1626
<code>
import active_directory
group = active_directory.find_group ("name-of-group")
# or group = active_directory.AD_object ("group-moniker")
user = active_directory.find_user ("name-of-user")
# or user = active_directory.AD_object ("user-moniker")
group.Remove (user.path ())
</code>
Obviously, for something this simple using an extra module
is overkill. You might as well:
<code>
import win32com.client
group = win32com.client.GetObject ("group-moniker")
group.Remove ("user-moniker")
</code>
NB I haven't tried these, I've just translated them
from the Cookbook site!
TJG