2010-10-25 14 views
8

मैं एक डब्ल्यूसीएफ सेवा के लिए एक कस्टम उपयोगकर्ता नाम/पासवर्ड सत्यापनकर्ता बना रहा हूं और कॉन्फ़िगरेशन आइटम customUserNamePasswordValidatorType भर में चला गया। मैं उदाहरणों का पालन करके अपना कोड काम करने में सक्षम हूं, लेकिन मुझे समझ में नहीं आता कि क्या हो रहा है। दुर्भाग्यवश, MSDN article अधिक जानकारी प्रदान नहीं करता है।customUserNamePasswordValidatorType के साथ क्या चल रहा है?

<serviceCredentials> 
    <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Microsoft.ServiceModel.Samples.CalculatorService.CustomUserNameValidator, service" /> 
</serviceCredentials> 

मैं समझने के लिए दो पैरामीटर customUserNamePasswordValidatorType कर रहे हैं कोशिश कर रहा हूँ: "Microsoft.ServiceModel.Samples.CalculatorService.CustomUserNameValidator" और "सेवा"

यह नमूना कि माइक्रोसॉफ्ट प्रदान करता है।

क्या कोई मुझे समझने में मदद कर सकता है कि इन पैरामीटर का क्या अर्थ है?

धन्यवाद!

उत्तर

10

यह पहली पैरामीटर समारोह कस्टम सत्यापन के पूरी तरह से योग्य नाम है। दूसरा पैरामीटर विधानसभा के नाम है कि समारोह में निहित है है।

कैसे कस्टम प्रमाणकों (थोड़ा संशोधित अपने उदाहरण फिट करने के लिए)

namespace Microsoft.ServiceModel.Samples.CalculatorService 
{ 
    public class CustomUserNameValidator : UserNamePasswordValidator 
    { 
    // This method validates users. It allows in two users, 
    // test1 and test2 with passwords 1tset and 2tset respectively. 
    // This code is for illustration purposes only and 
    // MUST NOT be used in a production environment because it 
    // is NOT secure. 
    public override void Validate(string userName, string password) 
    { 
     if (null == userName || null == password) 
     { 
     throw new ArgumentNullException(); 
     } 

     if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset")) 
     { 
     throw new FaultException("Unknown Username or Incorrect Password"); 
     } 
     } 
    } 
} 

उपयोग करने के लिए की a much better example से लिया ऊपर एक के अंदर अनुपालन किया जाएगा असेंबली नाम service

+0

बढ़िया! धन्यवाद! – Jacob

6

पहले भाग पूरी तरह से नाम स्थान से योग्य वर्ग के नाम है, दूसरा विधानसभा कक्षा में है।

+0

सहायता के लिए धन्यवाद! – Jacob

+0

प्रत्यक्ष और सटीक, धन्यवाद! –

संबंधित मुद्दे