?
Solved

remove user from Active Directory group

Posted on 2002-06-05
7
Medium Priority
?
586 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
Industry Leaders: 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

Industry Leaders: 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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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