Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Active Directory: how to delete a user from a group?

Reply
Thread Tools

Active Directory: how to delete a user from a group?

 
 
Dirk Hagemann
Guest
Posts: n/a
 
      05-02-2007
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?

Dirk

 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      05-02-2007
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

To delete a user, apparently:

<code>
import active_directory
user = active_directory.find_user ("name-of-user")
# or user = active_directory.AD_object ("user-moniker")
user.DeleteObject (0)
</code>

TJG
 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      05-02-2007
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
 
Reply With Quote
 
Dirk Hagemann
Guest
Posts: n/a
 
      05-04-2007
On 2 Mai, 17:48, Tim Golden <(E-Mail Removed)> wrote:
> Tim Golden wrote:
> >Dirk Hagemannwrote:
> >> 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 fromhttp://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


Hi Tim!

The first code does exactly what I want - thanks a lot again for your
help.

Dirk

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Catching user switching and getting current active user from root on linux mpnordland Python 24 12-31-2010 12:59 AM
diff between user defined delete and delete[] mail.dsp@gmail.com C++ 4 11-17-2008 01:39 PM
Rolling upgrade of Active-active cluster for SQL server 2000 =?Utf-8?B?U3VzaGls?= MCSE 1 02-16-2006 05:57 AM
Thunderbird filters "active" but not "active" =?ISO-8859-2?Q?Rafa=B3_=A3o=BFy=F1ski?= Firefox 5 05-18-2005 07:27 AM



Advertisments