示例#1
0
        async Task <HandlerReply> IRequestHandler <BindRequest> .Handle(ClientContext context, LdapEvents eventListener, BindRequest operation)
        {
            Dictionary <string, List <string> > rdn = RdnParser.ParseRdnString(operation.Name);
            AuthenticationEvent authEvent           = new AuthenticationEvent(rdn, operation.Authentication);
            bool success = await eventListener.OnAuthenticationRequest(context, authEvent);

            if (success)
            {
                context.IsAuthenticated = true;
                context.Rdn             = rdn;

                LdapResult   ldapResult   = new LdapResult(LdapResult.ResultCodeEnum.Success, null, null);
                BindResponse bindResponse = new BindResponse(ldapResult);
                return(new HandlerReply(new List <IProtocolOp> {
                    bindResponse
                }));
            }
            else
            {
                context.IsAuthenticated = false;
                context.Rdn             = new Dictionary <string, List <string> >();

                LdapResult   ldapResult   = new LdapResult(LdapResult.ResultCodeEnum.InappropriateAuthentication, null, null);
                BindResponse bindResponse = new BindResponse(ldapResult);
                return(new HandlerReply(new List <IProtocolOp> {
                    bindResponse
                }));
            }
        }
示例#2
0
 public void TestParseRdnString(string rdn, Dictionary <string, List <string> > expected)
 {
     Assert.Equal(expected, RdnParser.ParseRdnString(rdn));
 }