Here's code,that i think,add user in group
....
DirectoryEntry grp=new DirectoryEntry( GroupName);
MessageBox.Show (GroupName,"gro up to add");
try
{
if (grp!=null)
{
grp.Invoke("Add ",new object[] {User.Path.ToSt ring()});}
grp.CommitChang es();
}
catch (Exception ex)
{
MessageBox.Show (ex.Message,"An Exception occured during adding to group");
}
}
....
GroupName is something like
LDAP://cn=Admin,ou=Adm inistration,ou= main office,dc=beta-comp,dc.com
It generate exception:
"Exception has been thrown by the target of an invocation"
Help me please!
P.S. Very sorry for my english :) 3 22203
>Here's code,that i think,add user in group ... DirectoryEnt ry grp=new DirectoryEntry( GroupName); MessageBox.Sho w(GroupName,"gr oup to add"); try { if (grp!=null) { grp.Invoke("Add ",new object[] {User.Path.ToSt ring()});} grp.CommitChang es(); } catch (Exception ex) { MessageBox.Show (ex.Message,"An Exception occured during adding to group"); } } ... GroupName is something like LDAP://cn=Admin,ou=Adm inistration,ou= main office,dc=beta-comp,dc.com
What's the user LDAP path look like??
You're trying to add a user to a group, right?
Why so complicated ?? Basically, you can do:
DirectoryEntry grp = new DirectoryEntry( GroupName);
try
{
if (grp!=null)
{
grp.Properties["member"].Add(strUserLDA PString);
grp.CommitChang es();
}
catch (Exception ex)
{
MessageBox.Show (ex.Message,"An Exception occured during adding
to group");
}
}
That should do the trick.
Check out the "System.Directo ryServices Portal" on MSDN: http://msdn.microsoft.com/library/en...sds/portal.asp
It contains TONS of samples in both VB.NET and C# - see here http://msdn.microsoft.com/library/en...e_examples.asp
(C#) http://msdn.microsoft.com/library/en...e_examples.asp
(VB.NET)
and tons of background info on S.DS- well worth a visit !
Marc
Thank you very much for help,it's really works.
Marc Scheuner [MVP ADSI] <m.********@ino va.SPAMBEGONE.c h> wrote in message news:<2b******* *************** **********@4ax. com>... Here's code,that i think,add user in group ... DirectoryEnt ry grp=new DirectoryEntry( GroupName); MessageBox.Sho w(GroupName,"gr oup to add"); try { if (grp!=null) { grp.Invoke("Add ",new object[] {User.Path.ToSt ring()});} grp.CommitChang es(); } catch (Exception ex) { MessageBox.Show (ex.Message,"An Exception occured during adding to group"); } } ... GroupName is something like LDAP://cn=Admin,ou=Adm inistration,ou= main office,dc=beta-comp,dc.com
What's the user LDAP path look like??
You're trying to add a user to a group, right?
Why so complicated ?? Basically, you can do:
DirectoryEntry grp = new DirectoryEntry( GroupName); try { if (grp!=null) { grp.Properties["member"].Add(strUserLDA PString); grp.CommitChang es(); } catch (Exception ex) { MessageBox.Show (ex.Message,"An Exception occured during adding to group"); } }
That should do the trick.
Check out the "System.Directo ryServices Portal" on MSDN: http://msdn.microsoft.com/library/en...sds/portal.asp
It contains TONS of samples in both VB.NET and C# - see here http://msdn.microsoft.com/library/en...e_examples.asp (C#) http://msdn.microsoft.com/library/en...e_examples.asp (VB.NET)
and tons of background info on S.DS- well worth a visit !
Marc
Thank you very much for help,it's really works.
Marc Scheuner [MVP ADSI] <m.********@ino va.SPAMBEGONE.c h> wrote in message news:<2b******* *************** **********@4ax. com>... Here's code,that i think,add user in group ... DirectoryEnt ry grp=new DirectoryEntry( GroupName); MessageBox.Sho w(GroupName,"gr oup to add"); try { if (grp!=null) { grp.Invoke("Add ",new object[] {User.Path.ToSt ring()});} grp.CommitChang es(); } catch (Exception ex) { MessageBox.Show (ex.Message,"An Exception occured during adding to group"); } } ... GroupName is something like LDAP://cn=Admin,ou=Adm inistration,ou= main office,dc=beta-comp,dc.com
What's the user LDAP path look like??
You're trying to add a user to a group, right?
Why so complicated ?? Basically, you can do:
DirectoryEntry grp = new DirectoryEntry( GroupName); try { if (grp!=null) { grp.Properties["member"].Add(strUserLDA PString); grp.CommitChang es(); } catch (Exception ex) { MessageBox.Show (ex.Message,"An Exception occured during adding to group"); } }
That should do the trick.
Check out the "System.Directo ryServices Portal" on MSDN: http://msdn.microsoft.com/library/en...sds/portal.asp
It contains TONS of samples in both VB.NET and C# - see here http://msdn.microsoft.com/library/en...e_examples.asp (C#) http://msdn.microsoft.com/library/en...e_examples.asp (VB.NET)
and tons of background info on S.DS- well worth a visit !
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jamie Fryatt |
last post by:
Hi everyone, here's what id like to do.
I have a table with 2 fields, name and value
I need to be able to add multiple records quickly, for example I need to add
name value
abc 1
abc 2
abc 3
|
by: hzgt9b |
last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure
in VSS gets an extra level of folders...
For example, here's the structure of the solution on my C:\
....\mySolution\mySolution.sln
....\mySolution\myProject1\myProject1.vbproj
-- and --
....\mySolution\myProject2\myProject2.vbproj
But after adding the solution to VSS the structure looks like this:
|
by: Robin Thomas |
last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental.
Anyway, quite often I am pulling data from a database, but then I need to
use that data to produce more data. A simple example would be: Let's say
Column1=StartDate and Column2=EndDate. In addition to displaying Column1 and
Column2, I need to do some calculations and display in as Column3.
The calculations are easy and can be done in the code-behind. How to display...
|
by: Sileesh |
last post by:
Hi
I have html table and a Button in an Aspx page. I am adding one row with
some textboxes to Html table each time i click on the Button thru Javascript.
Now problem is when when i try to collect the data in the Textboxes which i
added dynamically from server side, i am not able to do . Alos i tried to
bedug, the total no of rows in Html table does not reflect the dynamically
added rows.
|
by: vb |
last post by:
Hi,
I am new to .Net.
I am using a Combo Box in my windows forms. I am adding the items by
creating the instances and adding the same to the list.
My questions/doubts are:
1. If I have 25 to 30 options in each combo box and like that if we have 6
or 7 combo boxes in a form, isnt it a problem in creating that number of
instances everytime the form is opened/activated
2. How do I dispose the Combo Box items.
| |
by: Rudy |
last post by:
Hi all,
I know this is easy, just can't seem to get it. I have a windows form, and
a text box, with a value already in it. I need to add that value to a table.
It's just one value, so the entire row doesn't get filled. I have a
connection and all that stuff.
Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPlaceBet.Click
' Dim Myds As Footbet.DStable
'...
|
by: Sri |
last post by:
How do you add an n-bit number in C?
Regards,
Sri
|
by: Kadett |
last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control
at run-time and filling it with some records (let's say 10 000). This
operation seems to be quite fast, but when I call Controls.Add(list),
where list is my ListView control, then program hangs for minute. It seems
like this time depends on number of records added to control. So probably
when adding control to my form, those records are actualy added at this time...
|
by: AndyL69 |
last post by:
Hello
I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the inherented ACE are still available.
What's wrong ? I don't understand the difference between \\server\share and \\server\share\directory while adding a ACE
AndyL
Sample:
\\myserver\myshare
Inherited ACE: Administrators, Network Service
|
by: Jason |
last post by:
Hello,
I am trying to utilitze the AJAX Control toolkit in my asp.net project. I
have added a reference to AjaxControlToolkit.dll, and in my page, added
these lines of code:
<ajaxToolkit:ToolkitScriptManager runat="Server"
EnableScriptGlobalization="true" EnableScriptLocalization="true"
ID="ScriptManager1" />
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |