예제 #1
0
        internal ADObject GetDomain()
        {
            this.Init();
            GetADDomainRequest  getADDomainRequest = new GetADDomainRequest();
            GetADDomainResponse aDDomain           = this._topoMgmt.GetADDomain(this._sessionHandle, getADDomainRequest);

            if (aDDomain.Domain == null)
            {
                return(null);
            }
            else
            {
                ActiveDirectoryDomain domain = aDDomain.Domain;
                ADObject aDObject            = new ADObject();

                aDObject.Add("objectGUID", domain.ObjectGuid);
                aDObject.Add("name", domain.Name);
                aDObject.Add("distinguishedName", domain.DistinguishedName);
                aDObject.Add("objectClass", domain.ObjectClass);
                aDObject.Add("msDS-AllowedDNSSuffixes", domain.AllowedDNSSuffixes);
                aDObject.Add("objectSid", new SecurityIdentifier(domain.DomainSID, 0));
                aDObject.Add("msDS-Behavior-Version", (ADDomainMode)domain.DomainMode);
                aDObject.Add("managedBy", domain.ManagedBy);
                aDObject.Add("msDS-LogonTimeSyncInterval", domain.LastLogonReplicationInterval);
                aDObject.Add("SubordinateReferences", domain.SubordinateReferences);
                aDObject.Add("DNSRoot", domain.DNSRoot);
                aDObject.Add("LostAndFoundContainer", domain.LostAndFoundContainer);
                aDObject.Add("DeletedObjectsContainer", domain.DeletedObjectsContainer);
                aDObject.Add("QuotasContainer", domain.QuotasContainer);
                aDObject.Add("ReadOnlyReplicaDirectoryServers", domain.ReadOnlyReplicaDirectoryServer);
                aDObject.Add("ReplicaDirectoryServers", domain.ReplicaDirectoryServer);
                aDObject.Add("LinkedGroupPolicyObjects", domain.AppliedGroupPolicies);
                aDObject.Add("ChildDomains", domain.ChildDomains);
                aDObject.Add("ComputersContainer", domain.ComputersContainer);
                aDObject.Add("DomainControllersContainer", domain.DomainControllersContainer);
                aDObject.Add("ForeignSecurityPrincipalsContainer", domain.ForeignSecurityPrincipalsContainer);
                aDObject.Add("Forest", domain.Forest);
                aDObject.Add("InfrastructureMaster", domain.InfrastructureMaster);
                aDObject.Add("NetBIOSName", domain.NetBIOSName);
                aDObject.Add("PDCEmulator", domain.PDCEmulator);
                aDObject.Add("ParentDomain", domain.ParentDomain);
                aDObject.Add("RIDMaster", domain.RIDMaster);
                aDObject.Add("SystemsContainer", domain.SystemsContainer);
                aDObject.Add("UsersContainer", domain.UsersContainer);
                ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
                if (domain.ObjectTypes != null)
                {
                    aDPropertyValueCollection.AddRange(domain.ObjectTypes);
                }
                aDObject.ObjectTypes = aDPropertyValueCollection;
                return(aDObject);
            }
        }
예제 #2
0
        private void PopulateADObjectFromWebServiceData(ActiveDirectoryObject inputWSObject, ADObject adobjectToPopulate)
        {
            adobjectToPopulate.DistinguishedName = inputWSObject.DistinguishedName;
            adobjectToPopulate.SetValue("name", inputWSObject.Name);
            adobjectToPopulate.ObjectClass = inputWSObject.ObjectClass;
            adobjectToPopulate.ObjectGuid  = new Guid?(inputWSObject.ObjectGuid);
            ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();

            aDPropertyValueCollection.AddRange(inputWSObject.ObjectTypes);
            adobjectToPopulate.ObjectTypes = aDPropertyValueCollection;
            adobjectToPopulate.SessionInfo = new ADSessionInfo(inputWSObject.ReferenceServer);
            if (this._adSession.SessionInfo.Credential != null)
            {
                adobjectToPopulate.SessionInfo.Credential = this._adSession.SessionInfo.Credential;
            }
            adobjectToPopulate.SessionInfo.AuthType = this._adSession.SessionInfo.AuthType;
            adobjectToPopulate.IsSearchResult       = true;
        }
예제 #3
0
		internal ADObject GetDomain()
		{
			this.Init();
			GetADDomainRequest getADDomainRequest = new GetADDomainRequest();
			GetADDomainResponse aDDomain = this._topoMgmt.GetADDomain(this._sessionHandle, getADDomainRequest);
			if (aDDomain.Domain == null)
			{
				return null;
			}
			else
			{
				ActiveDirectoryDomain domain = aDDomain.Domain;
				ADObject aDObject = new ADObject();

				aDObject.Add("objectGUID", domain.ObjectGuid);
				aDObject.Add("name", domain.Name);
				aDObject.Add("distinguishedName", domain.DistinguishedName);
				aDObject.Add("objectClass", domain.ObjectClass);
				aDObject.Add("msDS-AllowedDNSSuffixes", domain.AllowedDNSSuffixes);
				aDObject.Add("objectSid", new SecurityIdentifier(domain.DomainSID, 0));
				aDObject.Add("msDS-Behavior-Version", (ADDomainMode)domain.DomainMode);
				aDObject.Add("managedBy", domain.ManagedBy);
				aDObject.Add("msDS-LogonTimeSyncInterval", domain.LastLogonReplicationInterval);
				aDObject.Add("SubordinateReferences", domain.SubordinateReferences);
				aDObject.Add("DNSRoot", domain.DNSRoot);
				aDObject.Add("LostAndFoundContainer", domain.LostAndFoundContainer);
				aDObject.Add("DeletedObjectsContainer", domain.DeletedObjectsContainer);
				aDObject.Add("QuotasContainer", domain.QuotasContainer);
				aDObject.Add("ReadOnlyReplicaDirectoryServers", domain.ReadOnlyReplicaDirectoryServer);
				aDObject.Add("ReplicaDirectoryServers", domain.ReplicaDirectoryServer);
				aDObject.Add("LinkedGroupPolicyObjects", domain.AppliedGroupPolicies);
				aDObject.Add("ChildDomains", domain.ChildDomains);
				aDObject.Add("ComputersContainer", domain.ComputersContainer);
				aDObject.Add("DomainControllersContainer", domain.DomainControllersContainer);
				aDObject.Add("ForeignSecurityPrincipalsContainer", domain.ForeignSecurityPrincipalsContainer);
				aDObject.Add("Forest", domain.Forest);
				aDObject.Add("InfrastructureMaster", domain.InfrastructureMaster);
				aDObject.Add("NetBIOSName", domain.NetBIOSName);
				aDObject.Add("PDCEmulator", domain.PDCEmulator);
				aDObject.Add("ParentDomain", domain.ParentDomain);
				aDObject.Add("RIDMaster", domain.RIDMaster);
				aDObject.Add("SystemsContainer", domain.SystemsContainer);
				aDObject.Add("UsersContainer", domain.UsersContainer);
				ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
				if (domain.ObjectTypes != null) {
					aDPropertyValueCollection.AddRange(domain.ObjectTypes);
				}
				aDObject.ObjectTypes = aDPropertyValueCollection;
				return aDObject;
			}
		}
예제 #4
0
		private void PopulateADObjectFromWebServiceData(ActiveDirectoryObject inputWSObject, ADObject adobjectToPopulate)
		{
			adobjectToPopulate.DistinguishedName = inputWSObject.DistinguishedName;
			adobjectToPopulate.SetValue("name", inputWSObject.Name);
			adobjectToPopulate.ObjectClass = inputWSObject.ObjectClass;
			adobjectToPopulate.ObjectGuid = new Guid?(inputWSObject.ObjectGuid);
			ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
			aDPropertyValueCollection.AddRange(inputWSObject.ObjectTypes);
			adobjectToPopulate.ObjectTypes = aDPropertyValueCollection;
			adobjectToPopulate.SessionInfo = new ADSessionInfo(inputWSObject.ReferenceServer);
			if (this._adSession.SessionInfo.Credential != null)
			{
				adobjectToPopulate.SessionInfo.Credential = this._adSession.SessionInfo.Credential;
			}
			adobjectToPopulate.SessionInfo.AuthType = this._adSession.SessionInfo.AuthType;
			adobjectToPopulate.IsSearchResult = true;
		}
예제 #5
0
		internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property)
		{
			string str = null;
			int num = 0;
			this.Init();
			if (property == null || property.Count == 0)
			{
				return null;
			}
			else
			{
				ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
				ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num);
				ADAttributeSyntax propertyType = this._adSchema.GetPropertyType(str);
				string[] values = null;
				byte[][] numArray = null;
				ADAttributeSyntax aDAttributeSyntax = propertyType;
				switch (aDAttributeSyntax)
				{
					case ADAttributeSyntax.DirectoryString:
					case ADAttributeSyntax.DN:
					{
						aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
						break;
					}
					case ADAttributeSyntax.OctetString:
					{
						aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
						break;
					}
					case ADAttributeSyntax.SecurityDescriptor:
					{
						numArray = (byte[][])property.GetValues(typeof(byte[]));
						byte[][] numArray1 = numArray;
						for (int i = 0; i < (int)numArray1.Length; i++)
						{
							byte[] numArray2 = numArray1[i];
							ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
							activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2);
							aDPropertyValueCollection.Add(activeDirectorySecurity);
						}
						break;
					}
					case ADAttributeSyntax.Int:
					case ADAttributeSyntax.Enumeration:
					{
						values = (string[])property.GetValues(typeof(string));
						string[] strArrays = values;
						for (int j = 0; j < (int)strArrays.Length; j++)
						{
							string str1 = strArrays[j];
							aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo));
						}
						break;
					}
					case ADAttributeSyntax.Int64:
					{
						values = (string[])property.GetValues(typeof(string));
						string[] strArrays1 = values;
						for (int k = 0; k < (int)strArrays1.Length; k++)
						{
							string str2 = strArrays1[k];
							aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo));
						}
						break;
					}
					case ADAttributeSyntax.Bool:
					{
						values = (string[])property.GetValues(typeof(string));
						string[] strArrays2 = values;
						for (int l = 0; l < (int)strArrays2.Length; l++)
						{
							string str3 = strArrays2[l];
							if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
							{
								aDPropertyValueCollection.Add(false);
							}
							else
							{
								aDPropertyValueCollection.Add(true);
							}
						}
						break;
					}
					case ADAttributeSyntax.Oid:
					case ADAttributeSyntax.DNWithBinary:
					case ADAttributeSyntax.DNWithString:
					case ADAttributeSyntax.IA5String:
					case ADAttributeSyntax.PrintableString:
					{
						aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
						break;
					}
					case ADAttributeSyntax.GeneralizedTime:
					case ADAttributeSyntax.UtcTime:
					{
						values = (string[])property.GetValues(typeof(string));
						string[] strArrays3 = values;
						for (int m = 0; m < (int)strArrays3.Length; m++)
						{
							string str4 = strArrays3[m];
							aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType));
						}
						break;
					}
					case ADAttributeSyntax.Sid:
					{
						numArray = (byte[][])property.GetValues(typeof(byte[]));
						byte[][] numArray3 = numArray;
						for (int n = 0; n < (int)numArray3.Length; n++)
						{
							byte[] numArray4 = numArray3[n];
							aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0));
						}
						break;
					}
					default:
					{
						if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink)
						{
							aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
							break;
						}
						aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
						break;
					}
				}
				return aDPropertyValueCollection;
			}
		}
예제 #6
0
        internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property)
        {
            string str = null;
            int    num = 0;

            this.Init();
            if (property == null || property.Count == 0)
            {
                return(null);
            }
            else
            {
                ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
                ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num);
                ADAttributeSyntax propertyType      = this._adSchema.GetPropertyType(str);
                string[]          values            = null;
                byte[][]          numArray          = null;
                ADAttributeSyntax aDAttributeSyntax = propertyType;
                switch (aDAttributeSyntax)
                {
                case ADAttributeSyntax.DirectoryString:
                case ADAttributeSyntax.DN:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.OctetString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                    break;
                }

                case ADAttributeSyntax.SecurityDescriptor:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray1 = numArray;
                    for (int i = 0; i < (int)numArray1.Length; i++)
                    {
                        byte[] numArray2 = numArray1[i];
                        ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
                        activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2);
                        aDPropertyValueCollection.Add(activeDirectorySecurity);
                    }
                    break;
                }

                case ADAttributeSyntax.Int:
                case ADAttributeSyntax.Enumeration:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays = values;
                    for (int j = 0; j < (int)strArrays.Length; j++)
                    {
                        string str1 = strArrays[j];
                        aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Int64:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays1 = values;
                    for (int k = 0; k < (int)strArrays1.Length; k++)
                    {
                        string str2 = strArrays1[k];
                        aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Bool:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays2 = values;
                    for (int l = 0; l < (int)strArrays2.Length; l++)
                    {
                        string str3 = strArrays2[l];
                        if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            aDPropertyValueCollection.Add(false);
                        }
                        else
                        {
                            aDPropertyValueCollection.Add(true);
                        }
                    }
                    break;
                }

                case ADAttributeSyntax.Oid:
                case ADAttributeSyntax.DNWithBinary:
                case ADAttributeSyntax.DNWithString:
                case ADAttributeSyntax.IA5String:
                case ADAttributeSyntax.PrintableString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.GeneralizedTime:
                case ADAttributeSyntax.UtcTime:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays3 = values;
                    for (int m = 0; m < (int)strArrays3.Length; m++)
                    {
                        string str4 = strArrays3[m];
                        aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType));
                    }
                    break;
                }

                case ADAttributeSyntax.Sid:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray3 = numArray;
                    for (int n = 0; n < (int)numArray3.Length; n++)
                    {
                        byte[] numArray4 = numArray3[n];
                        aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0));
                    }
                    break;
                }

                default:
                {
                    if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink)
                    {
                        aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                        break;
                    }
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }
                }
                return(aDPropertyValueCollection);
            }
        }