Here's the code, But I have a question, If the thread principal don't have
permission to operate on Active Directory, why it sometimes work, the problem
is that the exception is not always thrown, sometimes it does everithing
right.
this is the call to the permission check:
AzManHelper.crearExtendedPrincipal();
if (AzManHelper.chequearAcceso(ConstantesObjetos.strENTIDAD,
ConstantesAzMan.strPERMISO_AGREGAR))
{
//code.
//ConstantesObjetos.strENTIDAD and ConstantesAzMan.strPERMISO_AGREGAR
//are constants. The operation definition in Azman is like
// "OtdMantenimientoEntidad.agregar"
}
The create extenden principal code is:
public static void crearExtendedPrincipal( )
{
// Revisar esto cuando se ponga en producción
// SugefIdentity identity = Thread.CurrentPrincipal.Identity as
SugefIdentity;
SugefIdentity identity = null;
/* si esta en componentes */
if (Thread.CurrentPrincipal.Identity is SugefIdentity)
{
identity = Thread.CurrentPrincipal.Identity as SugefIdentity;
}
/* si esta en web */
else
{
identity = new SugefIdentity(Thread.CurrentPrincipal.Identity,
"sicveca");
}
int i = identity.Name.IndexOf(@"\");
string domain = identity.Name.Substring(0,i);
string providerName = domain.ToUpper() + ".AzmanProvider";
string applicationName = identity.Application;
ExtendedPrincipal principal = ExtendedPrincipal.Create(identity);
Thread.CurrentPrincipal = principal;
principal.AuditIdentifier = "RemotingAuditIdentifier";
principal.AuthorizationProvider = providerName;
principal.AuthorizationParameters.Add(AzManProvider.ApplicationName,
applicationName);
}
The application where the problem most occur is a console application
running as domain user
Hope this helps. Thanks
[quoted text, click to view] "erick@csharpbox.com" wrote:
> Can you post some of the code?
> It may be a problem with authentication/impersonation. You should try to
> look at the System.Threading.Thread.CurrentPrincipal.Identity and see if
> the service (or thread principal) credentials have permission to operate
> on Active Directory.
>
>
> Erick Sgarbi
>
> > Hello, I work giving support to a system developed in .NET wich uses
> > Autorization Manager, Remoting, and Reflection.
> > I'm having trouble with the system at the production environment
> > because
> > sometime it launches an Exception with the message "A Directory
> > Service error
> > has occurred". I've noticed with this Exception is launched only in
> > Remoting
> > methods,
> > I did perform a test executing the same procedure in several ways
> > 1) with remoting, 2) with the Business Logic Layer, and 3)
> > with the Data Access Layer, the Exception us launched just when I use
> > remoting.
> > Can someone help mi with this?
> > Mi mails are
> > efonseca@lidersoft.com
> > efonsecab@gmail.com
>
>