Class DocumentArchiveFileImpersonationContext
Helper class for impersonation.
Inherited Members
Namespace: SuperOffice.Security.Util
Assembly: SoCore.dll
Syntax
public sealed class DocumentArchiveFileImpersonationContext
Examples
new DocumentArchiveFileImpersonationContext().Execute(() => {
// in here we are the correct user to access the document archive files, log folder etc
// do something as the configured Document Archive user (if not configured the original NetServer user will be used).
});
// we are now back to the original NetServer user
This way of impersonation is guaranteed to return to the original user, also during exception handling - thereby avoiding a potential security hole.
Constructors
DocumentArchiveFileImpersonationContext()
Helper class for impersonation.
Declaration
public DocumentArchiveFileImpersonationContext()
Examples
new DocumentArchiveFileImpersonationContext().Execute(() => {
// in here we are the correct user to access the document archive files, log folder etc
// do something as the configured Document Archive user (if not configured the original NetServer user will be used).
});
// we are now back to the original NetServer user
This way of impersonation is guaranteed to return to the original user, also during exception handling - thereby avoiding a potential security hole.
Methods
Execute(Action)
Helper class for impersonation.
Declaration
public void Execute(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action |
Examples
new DocumentArchiveFileImpersonationContext().Execute(() => {
// in here we are the correct user to access the document archive files, log folder etc
// do something as the configured Document Archive user (if not configured the original NetServer user will be used).
});
// we are now back to the original NetServer user
This way of impersonation is guaranteed to return to the original user, also during exception handling - thereby avoiding a potential security hole.
Execute(Func<Task>)
Helper class for impersonation.
Declaration
public Task Execute(Func<Task> action)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | action |
Returns
Type | Description |
---|---|
Task |
Examples
new DocumentArchiveFileImpersonationContext().Execute(() => {
// in here we are the correct user to access the document archive files, log folder etc
// do something as the configured Document Archive user (if not configured the original NetServer user will be used).
});
// we are now back to the original NetServer user
This way of impersonation is guaranteed to return to the original user, also during exception handling - thereby avoiding a potential security hole.
Execute<T>(Func<T>)
Helper class for impersonation.
Declaration
public T Execute<T>(Func<T> func)
Parameters
Type | Name | Description |
---|---|---|
Func<T> | func |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
Examples
new DocumentArchiveFileImpersonationContext().Execute(() => {
// in here we are the correct user to access the document archive files, log folder etc
// do something as the configured Document Archive user (if not configured the original NetServer user will be used).
});
// we are now back to the original NetServer user
This way of impersonation is guaranteed to return to the original user, also during exception handling - thereby avoiding a potential security hole.