Avatar of Member_2_1242703
Member_2_1242703
 asked on

Adding a user to an ActiveDirectory security group via ASP.NET(VB) page

I'm trying to add a user to a security group using the code below. I am continuing to get the error:

"The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)"

on the CommitChanges line. Any ideas??


Dim group As New DirectoryEntry("LDAP://xx.xxx.xxx.xxx/CN=ussrm-users,OU=Security Groups,OU=Groups,OU=xyz,OU=abc,OU=AMR,OU=myou,DC=mycorp,DC=org")
group.Properties("member").Add("LDAP://xx.xxx.xxx.xxx/sAMAccountName=myuser1,OU=Pending Users,OU=Users,OU=xyz,OU=abc,OU=AMR,OU=myou,DC=mycorp,DC=org")
group.CommitChanges()

Open in new window

ASP.NETVisual Basic.NETActive Directory

Avatar of undefined
Last Comment
Michael Pfister

8/22/2022 - Mon
Michael Pfister

The member attribute doesn't take an ADsPath. Remove the LDAP:// and it should be fine.
HTH
Michael Pfister

BTW, 0x80072035 means  "The  server is unwilling to process the request"
Meir Rivkin

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Member_2_1242703

ASKER
I have tried each of the following to no avail:


group.Properties("member").Add("xx.xxx.xxx.xxx/sAMAccountName=userID")
group.Properties("member").Add("sAMAccountName=userID")
group.Properties("member").Add("CN=LastName\, FirstName")
group.Properties("member").Add("10.208.251.125/CN=LastName\, FirstName")
group.Properties("member").Add("LastName, FirstName")

Open in new window

Member_2_1242703

ASKER
Our format for CN is LastName, FirstName and for sAMAccount its just the network logon. What is the property I should be using here?
ASKER CERTIFIED SOLUTION
Michael Pfister

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.