Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF: Cannot find my custom validator specified in web.config - customUserNamePasswordValidatorType - - Could not load file or assembly ... - help?
    text
    copied!<p>So I've basically got everything up and running with wsHttpBindings and my WCF service using custom authentication over HTTPS.</p> <p>The issue I'm having is with the customUserNamePasswordValidatorType:</p> <pre><code> &lt;serviceCredentials&gt; &lt;!-- Use our own custom validation --&gt; &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="CustomValidator.CustomUserNameValidator, CustomValidator"/&gt; &lt;/serviceCredentials&gt; </code></pre> <p>Following directions found <a href="http://nayyeri.net/custom-username-and-password-authentication-in-wcf-3-5" rel="nofollow noreferrer">here</a> I've created my custom class as well:</p> <pre><code>namespace CustomValidator { public class CustomUserNameValidator : UserNamePasswordValidator { public override void Validate(string userName, string password) { if (null == userName || null == password) { throw new ArgumentNullException(); } if (!AuthenticateUser(userName, password)) throw new SecurityTokenValidationException("Invalid Credentials"); </code></pre> <p>The error is "<strong>Could not load file or assembly 'CustomValidator' or one of its dependencies. The system cannot find the file specified.</strong>", and refers to the tail end of customUserNamePasswordValidatorType - "..., CustomValidator".</p> <p>I didn't think it was a problem having my custom validator in its own namespace and class, but I can't see what else to do to make this work.</p> <p>I've tried with/without the namespace at the beginning, swapping, etc - nothing.</p> <p>Hoping another pair of eyes can pick this out.</p> <p>Thanks.</p> <p><strong>EDIT system.serviceModel</strong></p> <pre><code> &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;!-- wsHttpBinding --&gt; &lt;wsHttpBinding&gt; &lt;binding name="wsHttpEndpointBinding"&gt; &lt;security mode="TransportWithMessageCredential"&gt; &lt;transport clientCredentialType="None" /&gt; &lt;message clientCredentialType="UserName" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;!-- webHttpBinding --&gt; &lt;webHttpBinding&gt; &lt;binding name="wsHttps" &gt; &lt;security mode="Transport"/&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;!-- Basic binding --&gt; &lt;basicHttpBinding&gt; &lt;binding name="TransportSecurity"&gt; &lt;security mode="Transport"&gt; &lt;message clientCredentialType="UserName"/&gt; &lt;!-- transport clientCredentialType="None"/--&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;!-- customBinding&gt; &lt;binding name="WebHttpBinding_IService"&gt; textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;/textMessageEncoding&gt; &lt;httpsTransport manualAddressing="false"/&gt; &lt;/binding&gt; &lt;/customBinding --&gt; &lt;!-- Another custom binding --&gt; &lt;customBinding&gt; &lt;binding name="CustomMapper"&gt; &lt;webMessageEncoding webContentTypeMapperType= "IndexingService.CustomContentTypeMapper, IndexingService" /&gt; &lt;httpTransport manualAddressing="true" /&gt; &lt;/binding&gt; &lt;/customBinding&gt; &lt;/bindings&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="false" /&gt; &lt;services&gt; &lt;service behaviorConfiguration="ServiceBehavior" name="Service"&gt; &lt;!-- Service Endpoints --&gt; &lt;!-- since we're hosting in IIS, baseAddress is not required &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="https://mysslserver.com/Service.svc"/&gt; &lt;/baseAddresses&gt; &lt;/host&gt; --&gt; &lt;endpoint address="https://mysslserver.com/Service.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="IService" name="wsHttpEndpoint"&gt; &lt;!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically. --&gt; &lt;!--identity&gt; &lt;dns value="https://mysslserver.com"/&gt; &lt;/identity--&gt; &lt;/endpoint&gt; &lt;!-- endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/ --&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="webBehavior"&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="ServiceBehavior"&gt; &lt;!-- Setup Security/Error Auditing --&gt; &lt;serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" /&gt; &lt;serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" httpsGetUrl="https://mysslserver.com/Service.svc"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;serviceCredentials&gt; &lt;!-- Use our own custom validation --&gt; &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="CustomValidator.CustomUserNameValidator, CustomValidator"/&gt; &lt;/serviceCredentials&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;!-- serviceBehaviors&gt; &lt;behavior name="ServiceBehavior"&gt; &lt;serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://mysslserver.com/Service.svc" /&gt; To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;/behavior--&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload