예제 #1
0
        public bool CheckdistinguishedNames(Guid transactionid, List <string> distinguishedNames, out ErrorCodeInfo error)
        {
            bool bResult = true;

            error = new ErrorCodeInfo();

            try
            {
                do
                {
                    string rootOuPath = ConfigADProvider.GetCompanyOuDistinguishedName();
                    foreach (string distinguishedName in distinguishedNames)
                    {
                        string ouPath = string.Empty;
                        if (distinguishedName.ToLower().Contains("cn="))
                        {
                            ouPath = distinguishedName.Substring(ouPath.IndexOf(',') + 1);
                        }
                        else
                        {
                            ouPath = distinguishedName;
                        }
                        do
                        {
                            ouPath = ouPath.Substring(ouPath.IndexOf(',') + 1);
                            if (distinguishedNames.Contains(ouPath))
                            {
                                bResult    = false;
                                error.Code = ErrorCode.HaveParentOu;
                                error.SetInfo(distinguishedName);
                                break;
                            }
                        } while (ouPath.ToLower().Contains("ou="));
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error("CheckdistinguishedNames", string.Empty, ex.ToString(), transactionid);
                error.Code = ErrorCode.Exception;
                bResult    = false;
            }

            return(bResult);
        }
예제 #2
0
        public bool CheckRootOu(Guid transactionid, string oudistinguishedName, List <ControlLimitOuInfo> controlLimitOus, List <SameLevelOuInfo> sameLevelOus, out ErrorCodeInfo error)
        {
            bool bResult = false;

            error = new ErrorCodeInfo();

            try
            {
                if (oudistinguishedName == ConfigADProvider.GetPublicOuDistinguishedName())
                {
                    bResult = true;
                }
                else
                {
                    foreach (ControlLimitOuInfo controlLimitOu in controlLimitOus)
                    {
                        if (oudistinguishedName.Equals(controlLimitOu.OUdistinguishedName))
                        {
                            bResult = true;
                            break;
                        }
                    }

                    foreach (SameLevelOuInfo sameLimitOu in sameLevelOus)
                    {
                        if (oudistinguishedName.Equals(sameLimitOu.SamelevelOuPath))
                        {
                            bResult = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error("CheckRootOu", string.Empty, ex.ToString(), transactionid);
                error.Code = ErrorCode.Exception;
                bResult    = false;
            }

            return(bResult);
        }