473,320 Members | 2,164 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,320 software developers and data experts.

Active Directory Error - The server is unwilling to process the request

Hi People, when I try to modify an active directory user programatically, I
receive the following exception:

The server is unwilling to process the request

Reading the microsoft web site, I found this article:
http://support.microsoft.com/default...b;EN-US;248717 that says the
following:

..........................

To Make Modifications Using ADSI Scripts
Active Directory Services Interfaces (ADSI) can make modifications to the
schema through its Lightweight Directory Access Protocol (LDAP) provider.
The code below determines the location of the schema, bind to the attribute
in the schema, and make the necessary changes to force it to replicate to
the GC.
Const ADS_PROPERTY_CLEAR = 1
' Declarations are commented for use with VBScript
Dim oRootDSE 'As IADs
Dim oConn 'As ADODB.Connection
Dim oRecordset 'As ADODB.Recordset
Dim strAttribute 'As String
Dim strADsPath 'As String
Dim oAttribute 'As IADs
Dim bReplicate 'As Boolean

strAttribute = "Department" 'Replace with the name of the attribute to
change replication
bReplicate = True 'Replicate to GC True/False

Set oConn = CreateObject("ADODB.Connection")
Set oRootDSE = GetObject("LDAP://RootDSE")

oConn.Provider = "ADsDSOObject"
oConn.Open "ADs Provider"

strQuery = "<LDAP://" & oRootDSE.Get("schemaNamingContext")
& ">;(&(objectClass=attributeSchema)(cn=" & strAttribute &
"));cn,adspath;subtree"
Set oRecordset = oConn.Execute(strQuery)
oRecordset.MoveFirst
strADsPath = oRecordset.Fields("ADsPath") 'store the path of the object in
the schema

Set oAttribute = GetObject(strADsPath) 'Get the object in the schema
If bReplicate Then
oAttribute.Put "isMemberOfPartialAttributeSet", True 'Set the property
to true
Else
oAttribute.PutEx ADS_PROPERTY_CLEAR, "isMemberOfPartialAttributeSet", 0
'Clear the property
End If

'Write to schema
oAttribute.SetInfo

'Clean Up
Set oAttribute = Nothing
Set oRootDSE = Nothing
oRecordset.Close
oConn.Close
Set oConn = Nothing
Set oRecordset = Nothing
If the above registry change is not made, the following error occurs
when attempting to run the script:

Error -2147016651 (80072035): Automation error. The server is unwilling to
process the request.
.........................
My code is the following:

public DataSet modifyUser(ContenedorUsuario v_objContenedorUsuario) {

string strFullName = v_objContenedorUsuario.obtenerNombre() +" "+
v_objContenedorUsuario.obtenerPrimerApellido() +" "+
v_objContenedorUsuario.obtenerSegundoApellido();

DirectoryEntry objNewUser = null;

try

{

/* get the current user */

objNewUser = getDirectoryEntry(v_objContenedorUsuario.getUnique Id());

}

catch(Exception e)

{

throw new Exception("Usuario no Existe y no se puede modificar");

}

if (objNuevoUsuario == null)

{

throw new Exception("Usuario no Existe y no se puede modificar");

}

try

{

#region invoke Properties
/* si no se setea esta propiedad, provoca una exception de: The server is
unwilling to process the request,

* para mas detalles ver:
http://support.microsoft.com/default...b;EN-US;248717 */

Boolean objBoolean = true;

objNuevoUsuario.Properties["isMemberOfPartialAttributeSet"].Value =
objBoolean;

/* seccion de atributos obligatorios de Active Directory */

invocarPropiedad(ref objNuevoUsuario,"name",strNombreCompleto);

invocarPropiedad(ref
objNuevoUsuario,"givenName",v_objContenedorUsuario .obtenerNombre());

invocarPropiedad(ref
objNuevoUsuario,"Description",v_objContenedorUsuar io.obtenerDescripcion());

invocarPropiedad(ref
objNuevoUsuario,"samAccountName",v_objContenedorUs uario.obtenerLogin());

/* Seccion de atributos extendidos de Active Directory */

/* Para detalles ver:
http://www.microsoft.com/latam/techn...ws2k/chapt-20/ */

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute1",v_objContene dorUsuario.obtenerCedula()
);

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute2",v_objContene dorUsuario.obtenerCorreoEl
ectronico());

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute3",v_objContene dorUsuario.obtenerDepartam
ento());

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute4",v_objContene dorUsuario.obtenerEntidad(
));

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute5",v_objContene dorUsuario.obtenerJefeDire
cto());

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute6",v_objContene dorUsuario.obtenerNombre()
);

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute7",v_objContene dorUsuario.obtenerPrimerAp
ellido());

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute8",v_objContene dorUsuario.obtenerPuesto()
);

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute9",v_objContene dorUsuario.obtenerSegundoA
pellido());

invocarPropiedad(ref
objNuevoUsuario,"extensionAttribute10",v_objConten edorUsuario.obtenerTelefon
o());

/* solamente modifica el password si esta definido */

if(v_objContenedorUsuario.obtenerClave() != "" &&
v_objContenedorUsuario.obtenerClave() != null)

{

objNuevoUsuario.Invoke("SetPassword", new object[]
{v_objContenedorUsuario.obtenerClave() });

}

#endregion

/* Hace "Commit" de los cambios, para asegurar que se realicen en el Active
Directory */

objNuevoUsuario.CommitChanges();

/* se retorna el objeto correspondiente al nuevo usuario */

return convertirUsuarioADataSet(objNuevoUsuario);

}

catch(Exception e)

{

throw e;

}

}

I'm using a user with full rights to modify the active directory. Any idea
why the The server is unwilling to process the request exception???
Jul 21 '05 #1
0 15809

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

Similar topics

0
by: microsoft | last post by:
Hi People, when I try to modify an active directory user programatically, I receive the following exception: The server is unwilling to process the request Reading the microsoft web site, I...
10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
1
by: Angelo | last post by:
Hi, I've been trying to create a user in Active Directory. So far this works, however default the user is disabled. I've been trying so much code to enable the user, but without success, perhaps...
9
by: JTrigger | last post by:
When I compile my project using the IDE on a development machine it works just fine. When I compile it on the server using csc.exe, I get the following error when I try to bring it up in the web...
1
by: Derek Martin | last post by:
This seems to be a common problem in ASP.Net: Try Dim mystuff As DirectoryEntry = Session("myDirectoryEntry") mystuff.Properties("extensionAttribute1")(0) = "yes" mystuff.CommitChanges() Catch...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
3
by: Susan | last post by:
Hello all, My ASP.NET application seems to have intermittent problems when connecting to Active Directory server. Most of the time the Active Directory app works fine then suddenly fails and...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
1
by: Tim | last post by:
Folks, I have 3 loosely linked problems which I am would appreciate feedback on. 1). T-Sql and Active directory roles. We want to be able to control access to data within a table based on a...
5
by: wak0 | last post by:
Hi, I hope you guys can help me. I need to build a form that request username and password on ASP not ASP.net (sorry to clarify but i got some responses in other forums in .net) This form will...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.