Hi there,
I have a web app that adds user into w2k3 server and adds it to the
administrator group. The code snippet is something like this:
try
{
DirectoryEntry AD = new DirectoryEntry( "WinNT://" +
in0.IPAddress + ",computer" , in1.userName, decryptData(in1 .password),
AuthenticationT ypes.Secure);
// Create super user
DirectoryEntry NewUser = AD.Children.Add (in2.userName, "user");
NewUser.Invoke( "SetPasswor d", new object[] {
decryptData(in2 .password) });
NewUser.Invoke( "Put", new object[] { "Descriptio n", "Maya
account creation" });
NewUser.CommitC hanges();
DirectoryEntry grp;
grp = AD.Children.Fin d("Administrato rs", "group");
// if (grp.Name != null) {grp.Invoke("Ad d", new Object[]
{NewUser.Path.T oString()});}
if (grp.Name != null)
grp.Invoke("Add ", new Object[] { NewUser.Path.To String() });
}
catch (Exception e)
{
throw onException("SF atalInternalExc eption",
"http://mrdp.m.hp.com", "Super user account creation failed !!!");
}
here the user creation is done but when it tries to add the user to
administrative group it fails. This happens only in web app. If I try the
same as console application it is successful. I am not sure if I am missing
anything if I run this as a web service.
Any help in this regard will be helpful.
Thanks
John 2 4030
John,
If it works in a console application and not in a web app, it means that
you are running with rights that the ASPNET (the default local user account
that ASP.NET runs under) does not have.
You should impersonate a user that has the appropriate rights for the
web app. I suggest for something like this, that you only do it for the
pages which will actually add the user, as having the whole site run with
elevated permissions is a bad idea.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"johnpremi" <jo*******@disc ussions.microso ft.comwrote in message
news:D2******** *************** ***********@mic rosoft.com...
Hi there,
I have a web app that adds user into w2k3 server and adds it to the
administrator group. The code snippet is something like this:
try
{
DirectoryEntry AD = new DirectoryEntry( "WinNT://" +
in0.IPAddress + ",computer" , in1.userName, decryptData(in1 .password),
AuthenticationT ypes.Secure);
// Create super user
DirectoryEntry NewUser = AD.Children.Add (in2.userName, "user");
NewUser.Invoke( "SetPasswor d", new object[] {
decryptData(in2 .password) });
NewUser.Invoke( "Put", new object[] { "Descriptio n", "Maya
account creation" });
NewUser.CommitC hanges();
DirectoryEntry grp;
grp = AD.Children.Fin d("Administrato rs", "group");
// if (grp.Name != null) {grp.Invoke("Ad d", new Object[]
{NewUser.Path.T oString()});}
if (grp.Name != null)
grp.Invoke("Add ", new Object[] {
NewUser.Path.To String() });
}
catch (Exception e)
{
throw onException("SF atalInternalExc eption",
"http://mrdp.m.hp.com", "Super user account creation failed !!!");
}
here the user creation is done but when it tries to add the user to
administrative group it fails. This happens only in web app. If I try the
same as console application it is successful. I am not sure if I am
missing
anything if I run this as a web service.
Any help in this regard will be helpful.
Thanks
John
"johnpremi" <jo*******@disc ussions.microso ft.comwrote in message
news:D2******** *************** ***********@mic rosoft.com...
Hi there,
I have a web app that adds user into w2k3 server and adds it to the
administrator group. The code snippet is something like this:
try
{
DirectoryEntry AD = new DirectoryEntry( "WinNT://" +
in0.IPAddress + ",computer" , in1.userName, decryptData(in1 .password),
AuthenticationT ypes.Secure);
// Create super user
DirectoryEntry NewUser = AD.Children.Add (in2.userName, "user");
NewUser.Invoke( "SetPasswor d", new object[] {
decryptData(in2 .password) });
NewUser.Invoke( "Put", new object[] { "Descriptio n", "Maya
account creation" });
NewUser.CommitC hanges();
DirectoryEntry grp;
grp = AD.Children.Fin d("Administrato rs", "group");
// if (grp.Name != null) {grp.Invoke("Ad d", new Object[]
{NewUser.Path.T oString()});}
if (grp.Name != null)
grp.Invoke("Add ", new Object[] {
NewUser.Path.To String() });
}
catch (Exception e)
{
throw onException("SF atalInternalExc eption",
"http://mrdp.m.hp.com", "Super user account creation failed !!!");
}
here the user creation is done but when it tries to add the user to
administrative group it fails. This happens only in web app. If I try the
same as console application it is successful. I am not sure if I am
missing
anything if I run this as a web service.
Any help in this regard will be helpful.
Thanks
John
If it succeeds from a console program it should work from a web application
too. What's the exact exception being thrown?
Are you sure that both userName and password are the same in both scenarios,
*and* that this user is member of the administrators group?
...
DirectoryEntry AD = new DirectoryEntry( "WinNT://" +
in0.IPAddress + ",computer" , in1.userName, decryptData(in1 .password),
AuthenticationT ypes.Secure);
...
Please note also that this is not using WMI, System.Director yServices are
wrapping ADSI.
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mathias Alvarsson |
last post by:
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 =
|
by: Technical Group |
last post by:
Friends,
Can anybody help me out by sending a piece of C# code showing how to add an
active directory user to a particular user group? If the group does not
exist, then create it.
Thanks in advance
-Hari
|
by: Andy_Alpha |
last post by:
Here's code,that i think,add user in group
....
DirectoryEntry grp=new DirectoryEntry(GroupName);
MessageBox.Show(GroupName,"group to add");
try
{
if (grp!=null)
{
grp.Invoke("Add",new object {User.Path.ToString()});}
|
by: Calvin Lai |
last post by:
Hi all,
I have a problem in creating web user control *programatically*. Problem as
follows:
1. WebUserControl1 contains a server side table named Table1
2. WebForm1 contain a server panel and server form.
3. In WebForm1.aspx.cs, I created a WebUserControl1 and attached it to panel
by:
WebUserControl1 oCtl = new WebUserControl1();
|
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
| |
by: James |
last post by:
I have a VB windows forms application that accesses a Microsoft Access
database that has been secured using user-level security. The
application is being deployed using No-Touch deployment. The objective
in utilizing this new deployment method is to reduce the maintenance
overhead as well as making it easier for my users to setup and run the
application initially. I have VS 2002, Windows XP, Access XP(2000
format).
He is my problem....
|
by: sheldonlg |
last post by:
I don't think my last attempt posted so here it is again.
This is a bit off-topic, but it does relate to php. This is the most
active related group that I can find, so even if it is off-topic I hope
you can help. (I have posted to alt.comp.mail.qmail, but that doesn't
have much participation).
Goal:
I want the create an account in qmail (which is written in php). What
I want to do is gather all the information from the user from a...
|
by: Daniel Knöpfel |
last post by:
Hello all
In our project we have been using the samAccount name to authenticate users
against the active directory. As the samAccountName is limited to 20
characters, we are going to use the userPrincipalName. Unfortunately, i
couldtnt make it work until now. I ve got a .Net programm that access the
active directory through the third party dll "Interop.ActiveDs.dll"
(namespace ActiveDs). The code to create the user with using the...
|
by: brixdotnet |
last post by:
Hi there!
I made own user control for displaying and editing content. In
Page_Load of this control is checked if user is authorized for editing
if so, button for editing is shown, otherwise controll works in
display only mode. I want now use this control to add new content. The
idea is that in another web form, let's call AddNewContent.aspx there
is placed MyContentControl and I want to run in Editing mode with all
fields reset to...
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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.
| |