Solved

remove user from Active Directory group

Posted on 2002-06-05
7
577 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
Comment Utility
Are you running it as an administrator?
0
 

Author Comment

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

Author Comment

by:chencc77
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 11

Expert Comment

by:thunderchicken
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now