Пример #1
0
        // Utils ////////////////////////////////////////////

        protected internal virtual string getDnForUser(string userId)
        {
            LdapUserEntity user = (LdapUserEntity)createUserQuery(org.camunda.bpm.engine.impl.context.Context.CommandContext).userId(userId).singleResult();

            if (user == null)
            {
                return("");
            }
            else
            {
                return(user.Dn);
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected LdapUserEntity transformUser(javax.naming.directory.SearchResult result) throws javax.naming.NamingException
        protected internal virtual LdapUserEntity transformUser(SearchResult result)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.naming.directory.Attributes attributes = result.getAttributes();
            Attributes     attributes = result.Attributes;
            LdapUserEntity user       = new LdapUserEntity();

            user.Dn        = result.NameInNamespace;
            user.Id        = getStringAttributeValue(ldapConfiguration.UserIdAttribute, attributes);
            user.FirstName = getStringAttributeValue(ldapConfiguration.UserFirstnameAttribute, attributes);
            user.LastName  = getStringAttributeValue(ldapConfiguration.UserLastnameAttribute, attributes);
            user.Email     = getStringAttributeValue(ldapConfiguration.UserEmailAttribute, attributes);
            return(user);
        }
Пример #3
0
        public virtual bool checkPassword(string userId, string password)
        {
            // prevent a null password
            if (string.ReferenceEquals(password, null))
            {
                return(false);
            }

            // engine can't work without users
            if (string.ReferenceEquals(userId, null) || userId.Length == 0)
            {
                return(false);
            }

            /*
             * We only allow login with no password if anonymous login is set.
             * RFC allows such a behavior but discourages the usage so we provide it for
             * user which have an ldap with anonymous login.
             */
            if (!ldapConfiguration.AllowAnonymousLogin && password.Equals(""))
            {
                return(false);
            }

            // first search for user using manager DN
            LdapUserEntity user = (LdapUserEntity)findUserById(userId);

            close();

            if (user == null)
            {
                return(false);
            }
            else
            {
                try
                {
                    // bind authenticate for user + supplied password
                    openContext(user.Dn, password);
                    return(true);
                }
                catch (LdapAuthenticationException)
                {
                    return(false);
                }
            }
        }