Esempio n. 1
0
        public HttpResponseMessage AddADRole(ADRole ADRole, Int32 id)
        {
            context.ADRoles.Add(ADRole);

            context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, ADRole));
        }
Esempio n. 2
0
        ///<summary>
        /// This method will update one new row into the database using the property Information
        /// </summary>
        ///
        /// <param name="aDRole" type="ADRole">This ADRole  will be updated in the database.</param>
        ///
        /// <returns>True if succeeded</returns>
        public bool Update(ADRole aDRole)
        {
            _aDRole = POS.DataLayer.ADRole.SelectOne(new POS.DataLayer.ADRolePrimaryKey(aDRole.RoleID));

            _aDRole.RoleName = aDRole.RoleName;
            _aDRole.RolePath = aDRole.RolePath;

            return(_aDRole.Update());
        }
Esempio n. 3
0
        /// <summary>
        /// This method will insert one new row into the database using the property Information
        /// </summary>
        ///
        /// <param name="aDRole" type="ADRole">This ADRole  will be inserted in the database.</param>
        ///
        /// <returns>True if succeeded</returns>
        public bool Insert(ADRole aDRole)
        {
            _aDRole          = new POS.DataLayer.ADRole();
            _aDRole.RoleID   = aDRole.RoleID;
            _aDRole.RoleName = aDRole.RoleName;
            _aDRole.RolePath = aDRole.RolePath;

            return(_aDRole.Insert());
        }
        // Token: 0x0600057B RID: 1403 RVA: 0x0001EB18 File Offset: 0x0001CD18
        private ADServerInfo InternalClone(string serverFqdn, ADRole?role = null)
        {
            if (string.IsNullOrEmpty(serverFqdn) && string.IsNullOrEmpty(this.Fqdn))
            {
                throw new NotSupportedException("ServerFqdn can't null if this.Fqdn is null.");
            }
            if (!string.IsNullOrEmpty(this.Fqdn) && !string.IsNullOrEmpty(serverFqdn) && !string.Equals(this.Fqdn, serverFqdn, StringComparison.OrdinalIgnoreCase))
            {
                throw new NotSupportedException("Current ADServerInfo already has serverName resolved. Names doesn't match");
            }
            int port = this.Port;

            if (role != null)
            {
                ADRole adserverRole = this.GetADServerRole();
                if (role.Value != adserverRole)
                {
                    if (ADRole.GlobalCatalog == role.Value)
                    {
                        port = 3268;
                    }
                    else
                    {
                        port = 389;
                    }
                }
            }
            ADServerInfo adserverInfo;

            if (!string.IsNullOrEmpty(this.PartitionFqdn))
            {
                adserverInfo = new ADServerInfo(serverFqdn ?? this.Fqdn, this.PartitionFqdn, port, this.writableNC, this.DnsWeight, this.authType, true);
            }
            else
            {
                adserverInfo = new ADServerInfo(serverFqdn ?? this.Fqdn, port, this.writableNC, this.DnsWeight, this.authType);
            }
            if (!string.IsNullOrEmpty(this.siteName))
            {
                adserverInfo.siteName = this.siteName;
            }
            if (!string.IsNullOrEmpty(this.ConfigNC))
            {
                adserverInfo.ConfigNC = this.ConfigNC;
            }
            if (!string.IsNullOrEmpty(this.RootDomainNC))
            {
                adserverInfo.RootDomainNC = this.RootDomainNC;
            }
            if (!string.IsNullOrEmpty(this.SchemaNC))
            {
                adserverInfo.SchemaNC = this.SchemaNC;
            }
            return(adserverInfo);
        }
Esempio n. 5
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="ADRolePrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class ADRole</returns>
        public ADRole SelectOne(ADRolePrimaryKey pk)
        {
            _aDRoleWCF = new ADRole();
            _aDRole    = POS.DataLayer.ADRoleBase.SelectOne(new POS.DataLayer.ADRolePrimaryKey(pk.RoleID));

            _aDRoleWCF.RoleID   = _aDRole.RoleID;
            _aDRoleWCF.RoleName = _aDRole.RoleName;
            _aDRoleWCF.RolePath = _aDRole.RolePath;

            return(_aDRoleWCF);
        }
Esempio n. 6
0
        public HttpResponseMessage DeleteADRole(ADRole ADRole, Int32 id)
        {
            ADRole ADRoleToDelete = context.ADRoles.Find(id);

            if (ADRoleToDelete == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, ADRole));
            }

            context.ADRoles.Remove(ADRoleToDelete);
            context.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, ADRoleToDelete));
        }
Esempio n. 7
0
        /// <summary>
        /// This method will return a list of objects representing all records in the table.
        /// </summary>
        ///
        /// <returns>list of objects of class ADRole in the form of object of ADRoleCollection </returns>
        public ADRoleCollection SelectAll()
        {
            ADRoleCollection aDRoleCollection = new ADRoleCollection();

            foreach (POS.DataLayer.ADRole _aDRole in POS.DataLayer.ADRoleBase.SelectAll())
            {
                _aDRoleWCF = new ADRole();

                _aDRoleWCF.RoleID   = _aDRole.RoleID;
                _aDRoleWCF.RoleName = _aDRole.RoleName;
                _aDRoleWCF.RolePath = _aDRole.RolePath;

                aDRoleCollection.Add(_aDRoleWCF);
            }
            return(aDRoleCollection);
        }
Esempio n. 8
0
        /// <summary>
        /// This method will return a list of objects representing the specified number of entries from the specified record number in the table
        /// using the value of the field specified
        /// </summary>
        ///
        /// <param name="field" type="string">Field of the class ADRole</param>
        /// <param name="fieldValue" type="object">Value for the field specified.</param>
        /// <param name="fieldValue2" type="object">Value for the field specified.</param>
        /// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
        /// <param name="orderByStatement" type="string">The field value to number.</param>
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        ///
        /// <returns>List of object of class ADRole in the form of an object of class ADRoleCollection</returns>
        public ADRoleCollection SelectByFieldPaged(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation, int pageSize, int skipPages, string orderByStatement)
        {
            ADRoleCollection aDRoleCollection = new ADRoleCollection();

            foreach (POS.DataLayer.ADRole _aDRole in POS.DataLayer.ADRoleBase.SelectByFieldPaged(field, fieldValue, fieldValue2, typeOperation, pageSize, skipPages, orderByStatement))
            {
                _aDRoleWCF = new ADRole();

                _aDRoleWCF.RoleID   = _aDRole.RoleID;
                _aDRoleWCF.RoleName = _aDRole.RoleName;
                _aDRoleWCF.RolePath = _aDRole.RolePath;

                aDRoleCollection.Add(_aDRoleWCF);
            }
            return(aDRoleCollection);
        }
Esempio n. 9
0
        /// <summary>
        /// This method will return a list of objects representing the specified number of entries from the specified record number in the table.
        /// </summary>
        ///
        /// <param name="pageSize" type="int">Number of records returned.</param>
        /// <param name="skipPages" type="int">The number of missing pages.</param>
        /// <param name="orderByStatement" type="string">The field value to number.</param>
        ///
        /// <returns>list of objects of class ADRole in the form of an object of class ADRoleCollection </returns>
        public ADRoleCollection SelectAllPaged(int?pageSize, int?skipPages, string orderByStatement)
        {
            ADRoleCollection aDRoleCollection = new ADRoleCollection();

            foreach (POS.DataLayer.ADRole _aDRole in POS.DataLayer.ADRoleBase.SelectAllPaged(pageSize, skipPages, orderByStatement))
            {
                _aDRoleWCF = new ADRole();

                _aDRoleWCF.RoleID   = _aDRole.RoleID;
                _aDRoleWCF.RoleName = _aDRole.RoleName;
                _aDRoleWCF.RolePath = _aDRole.RolePath;

                aDRoleCollection.Add(_aDRoleWCF);
            }
            return(aDRoleCollection);
        }
Esempio n. 10
0
        /// <summary>
        /// This method will get row(s) from the database using the value of the field specified
        /// </summary>
        ///
        /// <param name="field" type="string">Field of the class ADRole</param>
        /// <param name="fieldValue" type="object">Value for the field specified.</param>
        /// <param name="fieldValue2" type="object">Value for the field specified.</param>
        /// <param name="typeOperation" type="TypeOperation">Operator that is used if fieldValue2=null or fieldValue2="".</param>
        ///
        /// <returns>List of object of class ADRole in the form of an object of class ADRoleCollection</returns>
        public ADRoleCollection SelectByField(string field, object fieldValue, object fieldValue2, TypeOperation typeOperation)
        {
            ADRoleCollection aDRoleCollection = new ADRoleCollection();

            foreach (POS.DataLayer.ADRole _aDRole in POS.DataLayer.ADRoleBase.SelectByField(field, fieldValue, fieldValue2, typeOperation))
            {
                _aDRoleWCF = new ADRole();

                _aDRoleWCF.RoleID   = _aDRole.RoleID;
                _aDRoleWCF.RoleName = _aDRole.RoleName;
                _aDRoleWCF.RolePath = _aDRole.RolePath;

                aDRoleCollection.Add(_aDRoleWCF);
            }
            return(aDRoleCollection);
        }
        private ADServerInfo GetDirectoryServer(string partitionFqdn, ADRole role)
        {
            ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, ADRole>((long)this.GetHashCode(), "GetDirectoryServer PartitionFqdn {0}. Role {1}", partitionFqdn, role);
            LocatorFlags locatorFlags = LocatorFlags.ForceRediscovery | LocatorFlags.DirectoryServicesRequired | LocatorFlags.ReturnDnsName;
            string       text         = partitionFqdn;

            if (ADRole.GlobalCatalog == role)
            {
                ADObjectId rootDomainNamingContext = base.GetRootDomainNamingContext(partitionFqdn);
                ADObjectId domainNamingContext     = base.GetDomainNamingContext(partitionFqdn);
                if (!rootDomainNamingContext.DistinguishedName.Equals(domainNamingContext.DistinguishedName, StringComparison.OrdinalIgnoreCase))
                {
                    text = NativeHelpers.CanonicalNameFromDistinguishedName(rootDomainNamingContext.DistinguishedName);
                }
                locatorFlags |= LocatorFlags.GCRequired;
            }
            ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, string, LocatorFlags>((long)this.GetHashCode(), "GetDirectoryServer. Partition Fqdn {0} Parent Domain {1}. Flags {2}", partitionFqdn, text, locatorFlags);
            ADServerInfo         serverInfo           = new ADServerInfo(null, text, (ADRole.GlobalCatalog == role) ? 3268 : 389, null, 100, AuthType.Kerberos, true);
            PooledLdapConnection pooledLdapConnection = null;
            ADServerInfo         adserverInfo         = null;

            try
            {
                pooledLdapConnection = LdapConnectionPool.CreateOneTimeConnection(null, serverInfo, locatorFlags);
                if (!string.IsNullOrEmpty(pooledLdapConnection.SessionOptions.HostName))
                {
                    adserverInfo = pooledLdapConnection.ADServerInfo.CloneWithServerNameResolved(pooledLdapConnection.SessionOptions.HostName);
                }
                ExTraceGlobals.TopologyProviderTracer.TraceDebug <string, string>((long)this.GetHashCode(), "GetDirectoryServer. Partition Fqdn {0}. Server {1}", partitionFqdn, pooledLdapConnection.SessionOptions.HostName ?? string.Empty);
            }
            finally
            {
                if (pooledLdapConnection != null)
                {
                    pooledLdapConnection.ReturnToPool();
                }
            }
            string          text2;
            LocalizedString localizedString;

            if (adserverInfo != null && SuitabilityVerifier.IsServerSuitableIgnoreExceptions(adserverInfo.Fqdn, ADRole.GlobalCatalog == role, null, out text2, out localizedString))
            {
                return(adserverInfo);
            }
            return(LdapTopologyProvider.FindDirectoryServerForForestOrDomain(text, null, ADRole.GlobalCatalog == role));
        }
 // Token: 0x0600057A RID: 1402 RVA: 0x0001EB08 File Offset: 0x0001CD08
 public ADServerInfo CloneAsRole(ADRole role)
 {
     return(this.InternalClone(null, new ADRole?(role)));
 }