//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private UserAndRolesData resultToUserRolesData(javax.naming.directory.SearchResult paramSearchResult, javax.naming.ldap.InitialLdapContext paramInitialLdapContext, LdapLoginUtil paramLdapLoginUtil, boolean paramBoolean) throws Exception
        private UserAndRolesData resultToUserRolesData(SearchResult paramSearchResult, InitialLdapContext paramInitialLdapContext, LdapLoginUtil paramLdapLoginUtil, bool paramBoolean)
        {
            UserAndRolesData userAndRolesData = new UserAndRolesData();
            PrincipalsData   principalsData   = new PrincipalsData();
            Attributes       attributes       = paramSearchResult.Attributes;
            string           str1             = StringUtils.getValueFromAttribute(attributes.get("displayName"));
            string           str2             = StringUtils.getValueFromAttribute(attributes.get("description"));
            string           str3             = StringUtils.getValueFromAttribute(attributes.get("sAMAccountName"));
            string           str4             = StringUtils.getValueFromAttribute(attributes.get("userPrincipalName"));

            if (string.ReferenceEquals(str3, null))
            {
                throw new Exception("sAMAccountName not found for: " + paramSearchResult.Name);
            }
            if (string.ReferenceEquals(str1, null))
            {
                str1 = str3;
            }
            if (string.ReferenceEquals(str4, null))
            {
                str4 = "";
            }
            principalsData.Name             = str1;
            principalsData.EMail            = str4;
            principalsData.PrincipalId      = str3;
            principalsData.Password         = "******";
            userAndRolesData.PrincipalsData = principalsData;
            if (!paramBoolean)
            {
                userAndRolesData.RolesData = new RolesData[0];
            }
            else
            {
                SearchControls searchControls = new SearchControls();
                searchControls.SearchScope         = 2;
                searchControls.ReturningAttributes = this.attrIDs;
                searchControls.TimeLimit           = 10000;
                string str5 = str3 + "," + Configuration.Options.get("baseCtxDN");
                string str6 = (string)Configuration.Options.get("roleRecursion");
                int    i    = 0;
                try
                {
                    i = int.Parse(str6);
                }
                catch (Exception)
                {
                    i = 0;
                }
                System.Collections.IList list      = paramLdapLoginUtil.findRolesOfUser(paramInitialLdapContext, searchControls, str3, str5, i, 0);
                List <object>            arrayList = new List <object>(list.Count);
                foreach (string str in list)
                {
                    arrayList.Add(new RolesData(str, str3, str, "Roles"));
                }
                userAndRolesData.RolesData = (RolesData[])arrayList.ToArray(typeof(RolesData));
            }
            return(userAndRolesData);
        }
Ejemplo n.º 2
0
        public virtual void makeLocalUserAndRolesData()
        {
            this.o_userRoleData = new UserAndRolesDataAnonymousInnerClass(this);
            PrincipalsData principalsData = new PrincipalsData();

            principalsData.PrincipalId         = getEncProperty("database.username");
            principalsData.Password            = getEncProperty("database.password");
            this.o_userRoleData.PrincipalsData = principalsData;
            string[]    arrayOfString    = getStringArrayProperty("database.accessibility");
            RolesData[] arrayOfRolesData = new RolesData[arrayOfString.Length];
            for (sbyte b = 0; b < arrayOfString.Length; b++)
            {
                RolesData rolesData = new RolesData();
                rolesData.PrincipalId = principalsData.PrincipalId;
                rolesData.Role        = arrayOfString[b];
                rolesData.RoleId      = arrayOfString[b];
                arrayOfRolesData[b]   = rolesData;
            }
            this.o_userRoleData.RolesData = arrayOfRolesData;
            this.o_userId   = principalsData.PrincipalId;
            this.o_password = principalsData.Password;
        }