Solved

remove user from Active Directory group

Posted on 2002-06-05
7
585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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