Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding Groups / Permissions to NT User in ASP

Posted on 2000-03-03
12
Medium Priority
?
537 Views
Last Modified: 2008-02-20
Hi folks...

I am writing a web page where an administrator can log on and add/delete/modify users.  The creation of a user works fine with the following code....

Dim oDomain, oUser,UserName

set oDomain = GetObject("WinNT://Paperless")
UserName = Trim(Request.Form("lblUsr"))
set oUser = oDomain.Create("User",UserName)

oUser.SetInfo
oUser.SetPassword(Request.Form("lblPW"))
oUser.SetInfo

Response.Write("User added...")

Here's my question (so far)

I need to add the groups to this user that had been created...

lblPW is the user's password (previous form)
lblUsr is the user's login Name (previous form)

I have the main group which is drpLevel (drop box from previous form)
and also a bunch of groups which is C1 (checkboxes previous form)

The adding the users works fine, but they must be in the groups.  I put the value in the checkbox on the previous form, but I am having a tough time figuring out how to add them to the groups.  I found on a PAQ the following code...

Dim Group as IADsGroup
Set Group = GetObject("WinNT://MyDomain/Groups/Administrators")
Group.Remove("WinNT://MyDomain/Users/UserA")
Group.Remove("WinNT://MyDomain/Users/UserB")

the error I got was the Dim Group Decloration (error '80005000')

I figure why this didn't work was because I may not have set up the ADSI correctly, or I haven't installed another component.  (I replaced the Remove above with Add, but never got to that point with the error on Dim Group line.

I hope that's enough information.
0
Comment
Question by:thunderchicken
[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
12 Comments
 
LVL 18

Expert Comment

by:mgfranz
ID: 2581287
Could it be as simple as slash direction?

Set Group = GetObject("WinNT:\\MyDomain\Groups\Administrators")
Group.Remove("WinNT:\\MyDomain\Users\UserA")
Group.Remove("WinNT:\\MyDomain\Users\UserB")
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2581311
No, I tried it, and the way my slashes were are fine.
0
 

Expert Comment

by:merk
ID: 2581549
Set oDomain = GetObject("WinNT://YourDomain")
Set oUser = oDomain.Create ("user", strUser)
Set oGroup = oDomain.GetObject("Group", strGroup)
oGroup.Add ("WinNT://YourDomain/"& strUser)
oUser.SetInfo

If you wanted to add this user to multiple groups, you'd have to step through the set oGroup statment (maybe you can add him to multiple groups at once, not sure, havent tried). I was just about to make a page to do this today actually. I was going to use an array and step through it to add the user to whatever groups they should belong to.

I successfully added the user to a single group using the above code. So i know it works. I just need to modify it now to add to multiple groups.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:thunderchicken
ID: 2581611
as long as i can get it to add one group, i'll figure out how to do it... i wont be into the office until Monday, so I'll let you know....  thanks
0
 
LVL 15

Expert Comment

by:robbert
ID: 2582436
Dim Group as IADsGroup
"the error I got was the Dim Group Decloration (error '80005000')"

That's because VBScript does not support variable types in variable declarations. Leave the "As" statement.
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2587285
With the

Dim Group as IADsGroup

I get this error

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/TechAdmin/UserManager/usercreated.asp, line 54

Dim oGroupPath as IADsGroup
---------------^

I tried the above suggestion, but I am wondering if this has anything to do with it.  I get an error without the as IADsGroup addon.

Still not working.....
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2588275
I have to reject this answer for now...  it's still not working correctly.  I think I need to know how to get the Dim statement to work.
0
 

Accepted Solution

by:
merk earned 400 total points
ID: 2588742
I dont see why you need the DIM statement? Its just declaring a variable, and you dont need to do that. If you take the code i posted, it should work, since i am using that same exact code, without declaring any variables.

As long as you dont have Option = Explicit anywhere on your page, you dont have to declare your variables.
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2588832
so your saying, i don't need to declare those groups at all?

so you are saying that those variables are predefined?
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2588959
Sorry, i figured it out.  I kept refreshing the screen and I guess the password didn't submit back over?  I don't know and I don't care.  It works now, thank you very much for your patience.  Stupid small things like that and I have successfully pulled out all of my hair!!!!!!
0
 

Expert Comment

by:merk
ID: 2589169
heh...i know the feeling...that'll be my next project...do it yourself hair plugs ;)p
0
 
LVL 11

Author Comment

by:thunderchicken
ID: 2605612
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

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…
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 informatio…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 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