Solved

remove user from Active Directory group

Posted on 2002-06-05
7
580 Views
Last Modified: 2012-08-13
I use RemoveUser method to remove a user from a group (not the domain), but i cannot sucess to remove the user. Is there any error in my code? THanks.


Public Sub RemoveUser(strUsername, strGroup, strDomain)

Dim adsGroup As ActiveDs.IADsGroup

  Set adsGroup = GetObject("WinNT://" + strDomain + "/" + strGroup)
  If adsGroup.IsMember(strUsername) Then
    adsGroup.Remove "WinNT://" + strDomain + "/" + strGroup + "/" + strUsername
  End If

End Sub
0
Comment
Question by:chencc77
7 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 7056240
Are you running it as an administrator?
0
 

Author Comment

by:chencc77
ID: 7056258
i have solve the error.
//solve the error
adsGroup.Remove "WinNT://" + strDomain + "/" + strUsername
0
 

Author Comment

by:chencc77
ID: 7056477
I have another question, I have to set the value for strDomain to get the users in the network. My question is how i set the GetObject method that it will default to get the users name for localHost.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 11

Expert Comment

by:thunderchicken
ID: 7056614
I don't believe localhost will work, you might have to get the NT Usergroup (ie. MYCOMPUTER)

then you can set it

Set adsGroup = GetObject("WinNT://MYCOMPUTER/" + username)
0
 

Author Comment

by:chencc77
ID: 7058004
Hi, I hope that my web application can dynamically get the localHost name so that whereever i put the web app, I do not have to change the strDomain value.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7516177
This question appears to have been abandoned. Please come back to this question and do the necessary evaluation or feedback. I will invite a Moderator to close this question if there's no reply from you after seven days.

I suggest
<PAQ with REFUND>

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **

hongjun
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7551581
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question