473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

AD adding user to a group in a different domain

In the creation-process of the new user, I also wan't to add it to a group
that exists in another domain in the same forrest. When I try this I get
these error-messages: "The object was not found on the server" or "The
server was unwilling to process the request".

I'm using the following code to add a user to a group:
string sGroupPath =
"LDAP://server1.domain1.test.com/CN=Test,CN=Users,DC=domain1,DC=test,DC=com"
;
string sUserPath =
"LDAP://server2.domain2.test.com/CN=John,CN=Users,DC=domain2,DC=test,DC=com"
;
DirectoryEntry oGroup = new DirectoryEntry( sGroupPath );
oGroup.Invoke("Add", new Object[] {sUserPath });

If I run the group-addingcode manually after the user has been replicated
between the domains, it works ok. But how do I do this in the same process
that creates the AD-user?

/Mathias
Nov 15 '05 #1
2 5141
>I'm using the following code to add a user to a group:
string sGroupPath =
"LDAP://server1.domain1.test.com/CN=Test,CN=Users,DC=domain1,DC=test,DC=com"
;
string sUserPath =
"LDAP://server2.domain2.test.com/CN=John,CN=Users,DC=domain2,DC=test,DC=com"
;
DirectoryEntry oGroup = new DirectoryEntry( sGroupPath );
oGroup.Invoke("Add", new Object[] {sUserPath });


First of all, you don't need to go the complicated way of invoking the
"Add" method on the group's native IADsGroup interface - just use the
group's "Children.Add" method.

Secondly, when adding a user to a group, you only have to specify the
user's DN - e.g. anything from the CN= part on. Do not specify the
LDAP:// and the server!

Thirdly, there are a number of issues mostly with permissions and
trusts when doing this - so you might run into problems based on your
setup.

So now, try this, and see if it works:

string sUserPath = "CN=John,CN=Users,DC=domain2,DC=test,DC=com"
DirectoryEntry oGroup = new DirectoryEntry( sGroupPath );
oGroup.Children.Add(sUserPath)

Marc

Nov 15 '05 #2
I tried as you suggested, but it didn't work. I got no error-messages at
all. Any ideas?

/Mathias
"Marc Scheuner [MVP ADSI]" <m.********@inova.SPAMBEGONE.ch> wrote in message
news:9f********************************@4ax.com...
I'm using the following code to add a user to a group:
string sGroupPath =


"LDAP://server1.domain1.test.com/CN=Test,CN=Users,DC=domain1,DC=test,DC=com

"
;
string sUserPath =


"LDAP://server2.domain2.test.com/CN=John,CN=Users,DC=domain2,DC=test,DC=com

"
;
DirectoryEntry oGroup = new DirectoryEntry( sGroupPath );
oGroup.Invoke("Add", new Object[] {sUserPath });


First of all, you don't need to go the complicated way of invoking the
"Add" method on the group's native IADsGroup interface - just use the
group's "Children.Add" method.

Secondly, when adding a user to a group, you only have to specify the
user's DN - e.g. anything from the CN= part on. Do not specify the
LDAP:// and the server!

Thirdly, there are a number of issues mostly with permissions and
trusts when doing this - so you might run into problems based on your
setup.

So now, try this, and see if it works:

string sUserPath = "CN=John,CN=Users,DC=domain2,DC=test,DC=com"
DirectoryEntry oGroup = new DirectoryEntry( sGroupPath );
oGroup.Children.Add(sUserPath)

Marc

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RobinB | last post by:
We gave created a web application that uses AD for authorization and authentication. The application can be used by domain users as well as the general public. What we currently have is 2 domains...
1
by: dbwmn2001 | last post by:
I have a SAP Server running SQL2000 on Windows 2003. Recently I migrated the server from a NT4 Domain to a AD Domain using ADMT (with SID Migration for users) and everything seems ok. Now, after...
4
by: Russ Ferrill | last post by:
I have a C# application in which I need to add one Active Directory group as a member of another group. I have tried using the same steps that work for adding a user to a group, but that isn't...
1
by: Ching-Lung | last post by:
Hi, Is there any way to add new user to local admin group in C# ASP.NET? Thanks, -CL
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
0
by: Mike | last post by:
I am trying to create a small app using visual studio 2005 (vb), and I want to be able to input the users name and add the domain user to the local remote desktop user group. Here is the code I...
5
by: Michael Howes | last post by:
I'm writing a utility to manage a machines *local* accounts in c# I am getting all the users in a specific Group just fine but when I want to get some of the information on each user from their...
2
by: Jim in Arizona | last post by:
I'm trying to do a check to see if a specific active directory user account exists in active directory AND a specific group. I can't seem to get the filter down right. I can do this to find a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.