AZMan: InitializeClientContextFromName with the error "The value is not in the expected range."

The following code does not work in InitializeClientContextFromName, and the value "Value is not in the expected range". It works on another developer machine.

any tips i should follow? I am not familiar with AzMan at all ...

    private List<string> SyncAzManRoles(ActiveDirectoryMembershipProvider provider)
    {
        List<string> userAzManRoles = new List<string>();

        AzAuthorizationStoreClass store = new AzAuthorizationStoreClass();
        if (store == null)
        {
            AuthTrace("Azman store is not available");
            throw new InvalidOperationException("The azman store is not available");
        }
        store.Initialize(0, ConfigurationManager.ConnectionStrings
                    ["LocalPolicyStore"].ConnectionString, null);

        IAzApplication3 app = store.OpenApplication(Security.ApplicationName, null) as IAzApplication3;
        if (app == null)
        {
            AuthTrace("Azman application is not available");
            throw new InvalidOperationException("The azman application is not available");
        }

        IAzClientContext3 clientContext = null;
        try
        {
            clientContext = app.InitializeClientContextFromName(_username,
                provider.Name, null) as IAzClientContext3;
+3
source share
1 answer

I solved this using the InitializeClientContextFromToken method instead of InitializeClientContextFromName.

In my case, it was used in an ASP.NET web application

ulong token = 0;

var principal = User as WindowsPrincipal;
if ( principal != null )
{
    var identity = (WindowsIdentity) principal.Identity;

    ViewBag.Identity = identity.Name;
    token = (ulong) identity.Token.ToInt64();
}

// Server 2008 or Vista required to use IAzClientContext3
// Using token 0 uses app pool identity
var _clientContext = (IAzClientContext3) _azManApp.InitializeClientContextFromToken( token );

, -, . , WindowsIdentity, Token.

.

+2

All Articles