Solved

remove user from Active Directory group

Posted on 2002-06-05
7
582 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
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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help editing script 3 84
IIS 7 and executing pages using localhost 16 24
ASP Classic Query that needs to display more information 18 31
Two decimal 5 25
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 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/…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

679 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