470,596 Members | 1,386 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

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 15361

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by JTrigger | last post: by
1 post views Thread by Derek Martin | last post: by
3 posts views Thread by Susan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.