Esempio n. 1
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public DefaultClient()
 {
     this.wsTransferClient        = new WsTransferClient();
     this.wsTransferFactoryClient = new WsTransferFactoryClient();
     this.wsEnumerationClient     = new WsEnumerationClient();
     this.mexClient       = new MexClient();
     this.alternateClient = new AlternateClient();
     this.resourceFactory = new RmResourceFactory();
     this.requestFactory  = new RmRequestFactory();
 }
Esempio n. 2
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public DefaultClient()
 {
     this.wsTransferClient = new WsTransferClient();
     this.wsTransferFactoryClient = new WsTransferFactoryClient();
     this.wsEnumerationClient = new WsEnumerationClient();
     this.mexClient = new MexClient();
     this.alternateClient = new AlternateClient();
     this.resourceFactory = new RmResourceFactory();
     this.requestFactory = new RmRequestFactory();
 }
Esempio n. 3
0
 public DefaultClient(string fimUrl, TimeSpan?receiveTimeout = null, int?maxReceivedMessageSize = null)
 {
     this.wsTransferClient        = new WsTransferClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsTransfer(fimUrl));
     this.wsTransferFactoryClient = new WsTransferFactoryClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsTransferFactory(fimUrl));
     this.wsEnumerationClient     = new WsEnumerationClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsEnumeration(fimUrl));
     this.mexClient       = new MexClient(Bindings.MetadataExchangeHttpBinding_IMetadataExchange(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.Mex(fimUrl));
     this.alternateClient = new AlternateClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.Alternate(fimUrl));
     this.resourceFactory = new RmResourceFactory();
     this.requestFactory  = new RmRequestFactory();
 }
Esempio n. 4
0
 public DefaultClient(string fimUrl, TimeSpan? receiveTimeout = null, int? maxReceivedMessageSize = null)
 {
     this.wsTransferClient = new WsTransferClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsTransfer(fimUrl));
     this.wsTransferFactoryClient = new WsTransferFactoryClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsTransferFactory(fimUrl));
     this.wsEnumerationClient = new WsEnumerationClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.WsEnumeration(fimUrl));
     this.mexClient = new MexClient(Bindings.MetadataExchangeHttpBinding_IMetadataExchange(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.Mex(fimUrl));
     this.alternateClient = new AlternateClient(Bindings.ServiceMultipleTokenBinding_Common(receiveTimeout, maxReceivedMessageSize), DefaultEndpoints.Alternate(fimUrl));
     this.resourceFactory = new RmResourceFactory();
     this.requestFactory = new RmRequestFactory();
 }
Esempio n. 5
0
 public DefaultClient(string fimUrl)
 {
     this.wsTransferClient = new WsTransferClient(Bindings.ServiceMultipleTokenBinding_Common, DefaultEndpoints.WsTransfer(fimUrl));
     this.wsTransferFactoryClient = new WsTransferFactoryClient(Bindings.ServiceMultipleTokenBinding_Common, DefaultEndpoints.WsTransferFactory(fimUrl));
     this.wsEnumerationClient = new WsEnumerationClient(Bindings.ServiceMultipleTokenBinding_Common, DefaultEndpoints.WsEnumeration(fimUrl));
     this.mexClient = new MexClient(Bindings.MetadataExchangeHttpBinding_IMetadataExchange, DefaultEndpoints.Mex(fimUrl));
     this.alternateClient = new AlternateClient(Bindings.ServiceMultipleTokenBinding_Common, DefaultEndpoints.Alternate(fimUrl));
     this.resourceFactory = new RmResourceFactory();
     this.requestFactory = new RmRequestFactory();
 }
Esempio n. 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="wsTransferConfigurationName">Name of the ws transfer endpoint configuration.</param>
        /// <param name="wsTransferFactoryConfigurationName">Name of the ws transfer factory endpoint configuration.</param>
        /// <param name="wsEnumerationConfigurationName">Name of the ws enumeration endpoint configuration.</param>
        /// <param name="mexConfigurationName">Name of the mex endpoint configuration.</param>
        public DefaultClient(
            String wsTransferConfigurationName,
            String wsTransferFactoryConfigurationName,
            String wsEnumerationConfigurationName,
            String mexConfigurationName,
            String alternateClientConfigurationName
            )
        {
            this.wsTransferClient        = new WsTransferClient(wsTransferConfigurationName);
            this.wsTransferFactoryClient = new WsTransferFactoryClient(wsTransferFactoryConfigurationName);
            this.wsEnumerationClient     = new WsEnumerationClient(wsEnumerationConfigurationName);
            this.mexClient       = new MexClient(mexConfigurationName);
            this.alternateClient = new AlternateClient(alternateClientConfigurationName);

            this.resourceFactory = new RmResourceFactory();
            this.requestFactory  = new RmRequestFactory();
        }
Esempio n. 7
0
        public static void OTPReset(string domain, string username, ContextualSecurityToken authNSecurityToken, ContextMessageProperty contextMessageProperty)
        {
            // Create Anonymouse RmPerson and set ObjectID to Domain\User
            // The ObjectID attribute will become ResourceReferenceProperty in the message header
            RmPerson    user = new RmPerson();
            RmReference domainAndUsernameReference = new RmReference();

            domainAndUsernameReference.DomainAndUserNameValue = domain + '\\' + username;
            user.ObjectID = domainAndUsernameReference;
            PutResponse putResponse;

            putResponse = new PutResponse();
            string STSEndpoint = String.Empty;
            bool   putSuccess  = false; //This should always stay false with these calls unless no password reset workflow or qa authn workflow is attached.

            var          alternateClient = new AlternateClient();
            var          mexClient       = new MexClient();
            XmlSchemaSet metadata        = mexClient.Get();
            var          requestFactory  = new RmRequestFactory(metadata);

            // Set ResetPassword to true
            // Need a transaction to watch changes to the user
            using (RmResourceChanges transaction = new RmResourceChanges(user))
            {
                transaction.BeginChanges();

                user.ResetPassword = "******";

                try
                {
                    if (transaction.RmObject.ObjectID.Value.Split('\\').Length != 2)
                    {
                        throw new ArgumentException("User Identity must be specified by netbios domain in this format: Domain name\\user name.");
                    }

                    PutRequest alternateEPrequest = requestFactory.CreatePutRequest(transaction);

                    try
                    {
                        alternateClient.Put(alternateEPrequest, out putResponse, authNSecurityToken, contextMessageProperty);
                        putSuccess = true;
                    }
                    catch (System.ServiceModel.FaultException <Microsoft.ResourceManagement.Client.Faults.AuthenticationRequiredFault> authNFault)
                    {
                        Microsoft.ResourceManagement.WebServices.WSResourceManagement.AuthenticationRequiredFault msAuthNFault =
                            new Microsoft.ResourceManagement.WebServices.WSResourceManagement.AuthenticationRequiredFault(authNFault.Detail.SecurityTokenServiceAddress,
                                                                                                                          authNFault.Detail.UserRegistered.GetValueOrDefault(),
                                                                                                                          authNFault.Detail.UserLockedOut.GetValueOrDefault());

                        ContextMessageProperty responseContext;

                        if (ContextMessageProperty.TryGet(putResponse.Message, out responseContext) == false)
                        {
                            throw new InvalidOperationException("Could not retrieve security context message property even though we received an AuthN Fault. Something is fundamentally broken. Ensure assembly versions are correct and upgrades did not change protocol.");
                        }

                        throw new AuthenticationRequiredException(authNFault.Reason.ToString(),
                                                                  msAuthNFault,
                                                                  responseContext);
                    }
                }
                finally
                {
                    if (putSuccess == true)
                    {
                        transaction.AcceptChanges();
                    }
                    else
                    {
                        transaction.DiscardChanges();
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="wsTransferConfigurationName">Name of the ws transfer endpoint configuration.</param>
        /// <param name="wsTransferFactoryConfigurationName">Name of the ws transfer factory endpoint configuration.</param>
        /// <param name="wsEnumerationConfigurationName">Name of the ws enumeration endpoint configuration.</param>
        /// <param name="mexConfigurationName">Name of the mex endpoint configuration.</param>
        public DefaultClient(
            String wsTransferConfigurationName,
            String wsTransferFactoryConfigurationName,
            String wsEnumerationConfigurationName,
            String mexConfigurationName,
            String alternateClientConfigurationName
            )
        {
            this.wsTransferClient = new WsTransferClient(wsTransferConfigurationName);
            this.wsTransferFactoryClient = new WsTransferFactoryClient(wsTransferFactoryConfigurationName);
            this.wsEnumerationClient = new WsEnumerationClient(wsEnumerationConfigurationName);
            this.mexClient = new MexClient(mexConfigurationName);
            this.alternateClient = new AlternateClient(alternateClientConfigurationName);

            this.resourceFactory = new RmResourceFactory();
            this.requestFactory = new RmRequestFactory();
        }
Esempio n. 9
0
        public static void OTPReset(string domain, string username, ContextualSecurityToken authNSecurityToken, ContextMessageProperty contextMessageProperty)
        {
            // Create Anonymouse RmPerson and set ObjectID to Domain\User
            // The ObjectID attribute will become ResourceReferenceProperty in the message header
            RmPerson user = new RmPerson();
            RmReference domainAndUsernameReference = new RmReference();
            domainAndUsernameReference.DomainAndUserNameValue = domain + '\\' + username;
            user.ObjectID = domainAndUsernameReference;
            PutResponse putResponse;
            putResponse = new PutResponse();
            string STSEndpoint = String.Empty;
            bool putSuccess = false; //This should always stay false with these calls unless no password reset workflow or qa authn workflow is attached.

            var alternateClient = new AlternateClient();
            var mexClient = new MexClient();
            XmlSchemaSet metadata = mexClient.Get();
            var requestFactory = new RmRequestFactory(metadata);

            // Set ResetPassword to true
            // Need a transaction to watch changes to the user
            using (RmResourceChanges transaction = new RmResourceChanges(user))
            {
                transaction.BeginChanges();

                user.ResetPassword = "******";

                try
                {
                    if (transaction.RmObject.ObjectID.Value.Split('\\').Length != 2)
                    {
                        throw new ArgumentException("User Identity must be specified by netbios domain in this format: Domain name\\user name.");
                    }

                    PutRequest alternateEPrequest = requestFactory.CreatePutRequest(transaction);

                    try
                    {
                        alternateClient.Put(alternateEPrequest, out putResponse, authNSecurityToken, contextMessageProperty);
                        putSuccess = true;
                    }
                    catch (System.ServiceModel.FaultException<Microsoft.ResourceManagement.Client.Faults.AuthenticationRequiredFault> authNFault)
                    {

                        Microsoft.ResourceManagement.WebServices.WSResourceManagement.AuthenticationRequiredFault msAuthNFault =
                            new Microsoft.ResourceManagement.WebServices.WSResourceManagement.AuthenticationRequiredFault(authNFault.Detail.SecurityTokenServiceAddress,
                                                                                             authNFault.Detail.UserRegistered.GetValueOrDefault(),
                                                                                             authNFault.Detail.UserLockedOut.GetValueOrDefault());

                        ContextMessageProperty responseContext;

                        if (ContextMessageProperty.TryGet(putResponse.Message, out responseContext) == false)
                        {
                            throw new InvalidOperationException("Could not retrieve security context message property even though we received an AuthN Fault. Something is fundamentally broken. Ensure assembly versions are correct and upgrades did not change protocol.");
                        }

                        throw new AuthenticationRequiredException(authNFault.Reason.ToString(),
                                                                 msAuthNFault,
                                                                 responseContext);
                    }
                }
                finally
                {
                    if (putSuccess == true)
                    {
                        transaction.AcceptChanges();
                    }
                    else
                    {
                        transaction.DiscardChanges();
                    }
                }
            }
        }