Greetings,
I am building a ASPX UI that will allow a HR representative manage the AD
Organization. I have a class that wraps a lot of AD work and I do things
like change password and update the GAL with Business information. I have
been able to write the code to get list of Direct Reports for a given user,
no problem. However, I am having trouble with how to set the 'manager' of a
AD user. Is it a property or a invoke function?
My code is simple like this...
public void AddDirectReport ( string ManagerAlias, string UserAlias )
{
DirectoryEntry deManager = GetUser(Manager Alias);
DirectoryEntry deDirectReport = GetUser(UserAli as);
this.SetPropert y( deDirectReport, "manager", this.GetPropert y( deManager,
"dn" ) );
deManager.Close ();
deDirectReport. Close();
}
public void SetProperty(Dir ectoryEntry oDE, string PropertyName, string
PropertyValue)
{
//check if the value is valid, otherwise dont update
if(PropertyValu e !=string.Empty)
{
//check if the property exists before adding it to the list
if(oDE.Properti es.Contains(Pro pertyName))
{
oDE.Properties[PropertyName][0]=PropertyValue;
oDE.CommitChang es();
}
else
{
oDE.Properties[PropertyName].Add(PropertyVa lue);
oDE.CommitChang es();
}
}
}
I have tried passing just the user alias instead of the Dn, and I get a
'Constrain violation error'. The code above, actually does not throw an
error, but it does not add the Manager either. Of course, GetUser() and
SetProperty() and GetProperty() are other members of the class to get the
Directory Entry of a user.
I have tried passing an empty string as the property value to try to remove
an already established Manager, but does not seem to work. The account that
makes the AD connection is a domain admin so it has rights..plus my other AD
code is running fine with this account on my staging environment. I have
waited 15 min to see if DC has been replicated, but no change to the AD
users I am testing with.
I have found example code using VB and ADSI calls, but C# and
DirectoryServic e namespace is scarce. The VB stuff looks like I am doing
the correct calls, but maybe I am missing something.
Anyone have experience in doing this with C# will help me greatly.
Thanx
Micah 0 2950 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kovac |
last post by:
The System.directoryservices.dll has an error, and this error was described
in http://support.microsoft.com/default.aspx?scid=kb;en-us;839424
At the moment we have Framework version v1.0.3705 and I have remove
System.directoryservices.dll from current Framework version v1.0.3705. In
state of old version I load die new System.directoryservices.dll from the
Framework version v1.1.4322.
I work with the following function of Joe Kaplan...
|
by: Sean |
last post by:
I figured I'd start this post on the .NET general forum instead of the
ADSI forum but feel free to nudge me along if I am looking in the wrong
place.
I am working with System.DirectoryServices to connect up to Active
Directory and make a couple of queries. The trouble starts as soon as I
attempt to compile this thing. I receive "Type
'System.DirectoryServices.SearchResultCollection' has no constructors." from
the following code. ...
|
by: Gaab |
last post by:
Hi Folks,
After the weekend I wanted to start working on my c#/asp.net project, but
when I tried to open it on my machine i got the following error:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
|
by: Stephanie Stowe |
last post by:
Hi. I am trying to read information out of the IIS metabase (v5.1). Observe
the following code:
using System;
using System.DirectoryServices;
using System.Reflection;
namespace ADSI1
{
class ConfigIIS
|
by: Rich Crusco via DotNetMonster.com |
last post by:
I am looking for a way to convert the following vbs script to c#
Const ADS_SECURE_AUTHENTICATION = 1
strADMIN = "adminaccount"
strPASSWORD = "password"
strUSER = "useraccount"
Set dso = GetObject("WinNT:")
Set srv = DSO.OpenDSObject("WinNT://servername/LanmanServer", strADMIN,
strPASSWORD, ADS_SECURE_AUTHENTICATION)
Set colResources = srv.Resources
| |
by: Keith Jakobs, MCP |
last post by:
Hi All....
I'm having a HECK of a time connecting to Active Directory using VB in
Visual Studio.NET 2003. Can anyone PLEASE help me?
All I am trying to do is list the current members of our Active Directory on
a web page. If I can connect to the AD interfaces, then I think I can
handle it from there.
I do have a VS.NET C# project successfully working and enumerating names,
|
by: killbill |
last post by:
Hi All,
I cannot figure out how i can delete user in AD with DirectoryServices
using ldap query?
Thanks
|
by: aamirghanchi |
last post by:
Hi,
I had .Net 1.1 app that worked fine. I recently migrated it to 2.0 but
am getting compilation errors, among which DirectoryServices classes
are not being recognized by the VS 2005 at build time. I can clearly
see the reference to System.DirectoryServices 2.0.0 GAC in the
reference list and there is no error where the Imports
System.DirectoryServices statement is.
Its listing errors all over for the classes under its namespace:
|
by: =?Utf-8?B?SmVycnkgQw==?= |
last post by:
I am using this code to get groups for a user and getting a error (5) on the
GetAuthorizationGroups() function .
There are two domains.
This function works on the local domain but does not work on the other domain.
Other functions work on the other domain like get all the users and get all
the groups and I can validate users on the other domain so I think I am
communciating with the other domain OK just not with the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |