当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryEntry.CommitChanges方法代码示例

本文整理汇总了C#中System.DirectoryServices.DirectoryEntry.CommitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.CommitChanges方法的具体用法?C# DirectoryEntry.CommitChanges怎么用?C# DirectoryEntry.CommitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DirectoryServices.DirectoryEntry的用法示例。


在下文中一共展示了DirectoryEntry.CommitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateNewUnit

		/// <summary>
		///  在根目录下创建组织单元
		/// </summary>
		/// <param name="ou">组织单元名称</param>
		/// <returns></returns>
		public  bool CreateNewUnit(string ou,string ouName)
		{
			bool result=false;

			///获得创建DirectoryEntry 的父对象
			string LDAPDomain ="/"+ Iadc.GetLDAPDomain();
			DirectoryEntry oDE= Iadc.GetDirectoryObject(LDAPDomain);			
			DirectoryEntry oDEC=new DirectoryEntry();

			//校验是否存在全局同名的组织单元
			if(!Iadch.CheckUnit(ou))
			{
				try
				{
					//创建子组织单元
					oDEC=oDE.Children.Add("OU="+ou,"organizationalunit");
					oDEC.Properties["description"].Value=ouName;
					oDEC.Properties["l"].Value="1";
					oDEC.CommitChanges();
					result=true;
				}					 
				catch(Exception err)
				{
					result=false;
				}
				
			}			

			return result;
		}
开发者ID:JuRogn,项目名称:OA,代码行数:35,代码来源:AD_Unit.cs

示例2: ChangePassword

 /// <summary>
 /// �������û�������
 /// </summary>
 /// <param name="UserName">���û���</param>
 /// <param name="OldPassword">������</param>
 /// <param name="NewPassword">������</param>
 /// <param name="DomainName">DNS����</param>
 /// <returns>�ɹ������棬���ɹ����ؼ�</returns>
 public static bool ChangePassword(string UserName, string OldPassword, string NewPassword, string DomainName)
 {
     try
     {
         string UserPrincipalName = UserName + "@" + DomainName;
         DirectoryEntry deRootDSE = new DirectoryEntry("LDAP://RootDSE", UserPrincipalName, OldPassword, AuthenticationTypes.Secure);
         DirectoryEntry deDomain = new DirectoryEntry("LDAP://" + deRootDSE.Properties["defaultNamingContext"].Value.ToString(), UserPrincipalName, OldPassword, AuthenticationTypes.Secure);
         DirectorySearcher dsSearcher = new DirectorySearcher();
         dsSearcher.SearchRoot = deDomain;
         dsSearcher.SearchScope = SearchScope.Subtree;
         dsSearcher.Filter = "(userPrincipalName=" + UserPrincipalName + ")";
         SearchResult srResult = dsSearcher.FindOne();
         if (srResult != null)
         {
             DirectoryEntry deUser = new DirectoryEntry(srResult.GetDirectoryEntry().Path, UserPrincipalName, OldPassword, AuthenticationTypes.Secure);
             deUser.Invoke("ChangePassword", new object[] { OldPassword, NewPassword });
             deUser.CommitChanges();
             return true;
         }
         else
             return false;
     }
     catch //(Exception ex)
     {
         return false;// ex.Message;
     }
 }
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:35,代码来源:DNS.cs

示例3: change

        public bool change(string username,string newpassword)
        {
            //Method to change the password of the remote machine
            DirectoryEntry dirEntry = null;
            string computerName = @"WinNT://" + this.target + "/" + username + ",user";
            try
            {
                dirEntry = new DirectoryEntry(computerName, this.adUser, this.adPassword);
                dirEntry.Invoke("SetPassword", new Object[] { newpassword});
                dirEntry.CommitChanges();

                try
                {
                    this.displayPopupInRemote();
                }
                catch (Exception e)
                {
                    this.setError("Unable to Display Message in Remote Machine - " +e.Message);
                }
                return true;
            }
            catch (Exception Ex)
            {
                this.setError(Ex.Message);
            }
            finally
            {
                if (dirEntry != null)
                    dirEntry.Dispose();
            }
            return false;
        }
开发者ID:CSPF-Founder,项目名称:RPasswordChanger,代码行数:32,代码来源:PasswordChanger.cs

示例4: btnEdit_Click

        private void btnEdit_Click(object sender, EventArgs e)
        {
            btnEdit.Enabled = false;
            DirectoryEntry dir = new DirectoryEntry("IIS://localhost/w3svc");
            dir.Properties["AspMaxRequestEntityAllowed"].Value = AspMaxRequestEntityAllowed.Text;
            dir.Properties["DefaultDoc"].Value = DefaultDoc.Text;
            dir.Properties["LogFileDirectory"].Value = LogFileDirectory.Text;
            dir.Properties["AspEnableParentPaths"].Value = AspEnableParentPaths.Checked;

            dir.Properties["ScriptMaps"].Value = Comm.GetScriptMaps(ScriptMaps.Text);

            dir.CommitChanges();

            SET_GZIP(GZIP.Checked, txtGzipPath.Text.Trim());

            SetMimeTypeProperty("IIS://localhost/MimeMap", ".flv", "flv-application/octet-stream", FLV.Checked);

            DirectoryEntry dir2 = new DirectoryEntry("IIS://localhost");
            dir2.Properties["EnableEditWhileRunning"].Value = EnableEditWhileRunning.Checked ? "1" : "0";
            dir2.CommitChanges();
            dir2.Invoke("SaveData", new object[0]);//保存配置到MetaBase.xml
            //dir2.Invoke("Backup", new object[3]{"haha", 1,1});
            //dir2.Invoke("Backup", new object[3] { "haha", 2, 1 });
            //dir2.Invoke("Backup", new object[3] { "haha", 3, 2 });
            //dir2.Invoke("Backup", new object[3] { "haha2", 1,1 });
            //dir2.Invoke("Restore",new object[3] { "haha2", 1,0 });
            btnEdit.Enabled = true;
            MessageBox.Show("OK");
        }
开发者ID:henrydem,项目名称:yongfa365doc,代码行数:29,代码来源:frmConfigs.cs

示例5: SetProperties

        public static void SetProperties(DirectoryEntry objectDE, Dictionary<string, object> properties)
        {
            if (objectDE == null)
            {
                throw new NullReferenceException("Parametr <objectDE> cannot be null");
            }

            if (properties == null)
            {
                throw new NullReferenceException("Parametr <properties> cannot be null");
            }

            foreach (var _key in properties.Keys) {
                try
                {
                    switch (_key)
                    {
                        case "info":
                        case "extensionAttribute1":
                            objectDE.Properties[_key].Value = (string)properties[_key];
                            break;
                    }

                    objectDE.CommitChanges();
                }
                catch(Exception ex)
                {
                    throw new Exception("Cannot set DirectoryEntry property <" + _key + ">");
                }
            }
        }
开发者ID:Eugene-Ishkov,项目名称:RestService,代码行数:31,代码来源:LdapObjectManager.cs

示例6: CreateVirtualDir

        public static void CreateVirtualDir(string virtualdirname, string logicDir)
        {
            DirectoryEntry rootEntry;
            rootEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/root");

            DirectoryEntry newVirDir;
            newVirDir = rootEntry.Children.Add(virtualdirname, "IIsWebVirtualDir");
            newVirDir.Invoke("AppCreate", true);

            newVirDir.CommitChanges();
            rootEntry.CommitChanges();

            newVirDir.Properties["AnonymousPasswordSync"][0] = true;
            newVirDir.Properties["Path"][0] = logicDir;//+ @"virtualdirentry\virtualname\";

            //设置的端口绑定数据
            //_newVirDir.Properties["ServerBindings"].Value =AppEntitys.WebAppInfor.HostIp+AppEntitys.WebAppInfor.HostProt+AppEntitys.WebAppInfor.AppDesc;

            //设置起始默认页:
            newVirDir.Properties["EnableDefaultDoc"][0] = true;
            newVirDir.Properties["DefaultDoc"][0] = "Default.aspx";

            //_newVirDir
            newVirDir.CommitChanges();
        }
开发者ID:felix-tien,项目名称:TechLab,代码行数:25,代码来源:W3WPTest.cs

示例7: SetPropertyValue

		protected override void SetPropertyValue(IOguObject srcOguObject, string srcPropertyName, DirectoryEntry entry, string targetPropertyName, string context, SetterContext setterContext)
		{
			string srcPropertyValue = GetNormalizeddSourceValue(srcOguObject, srcPropertyName, context);
			string targetPropertyValue = GetNormalizeddTargetValue(entry, targetPropertyName, context);

			if (srcPropertyValue != targetPropertyValue)
			{
				//entry.CommitChanges();
				try
				{
					entry.Properties[targetPropertyName].Value = srcOguObject.Properties[srcPropertyName];
					// entry.CommitChanges();
				}
				catch (DirectoryServicesCOMException ex)
				{
					if (ex.ErrorCode == -2147019886)
					{
						//对象已存在
						entry.Properties[targetPropertyName].Value = "TMP" + Environment.TickCount.ToString("X");
						entry.CommitChanges();
						SynchronizeContext.Current.DelayActions.Add(new DelayRenameCodeNameAction(srcOguObject, srcPropertyName, entry.NativeGuid, targetPropertyName));
					}
					else
					{
						throw;
					}
				}
			}
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:29,代码来源:CodeNamePropertySetter.cs

示例8: AddUserToLocalGroup

        protected bool AddUserToLocalGroup(string user, string groupName, string domainName, string machine)
        {
            bool reponse = false;

            try
            {
                string userPath = string.Format("WinNT://{0}/{1},user", domainName, user);
                string groupPath = string.Format("WinNT://{0}/{1},group", machine, groupName);

                using (DirectoryEntry groupe = new DirectoryEntry(groupPath))
                {

                    groupe.Invoke("Add", userPath);
                    groupe.CommitChanges();
                    groupe.Close();

                }
            }
            catch (System.DirectoryServices.DirectoryServicesCOMException E)
            {
                Log(Level.Error, E.Message.ToString());
            }

            return reponse;
        }
开发者ID:julienblin,项目名称:NAntConsole,代码行数:25,代码来源:AddUserToGroupTask.cs

示例9: CreateSite

 public void CreateSite(string port, string siteName, string siteExplain, string defaultDoc)
 {
     DirectoryEntry de = new DirectoryEntry("IIS://localhost/" + "w3svc");   //从活动目录中获取IIS对象。
     object[] prams = new object[2] { "IIsWebServer", Convert.ToInt32(siteName) };
     DirectoryEntry site = (DirectoryEntry)de.Invoke("Create", prams); //创建IISWebServer对象。
     site.Properties["KeyType"][0] = "IIsWebServer";
     site.Properties["ServerComment"][0] = siteExplain; //站点说明
     site.Properties["ServerState"][0] = 2; //站点初始状态,1.停止,2.启动,3
     site.Properties["ServerSize"][0] = 1;
     site.Properties["ServerBindings"].Add(":" + port + ":"); //站点端口
     site.CommitChanges(); //保存改变
     de.CommitChanges();
     DirectoryEntry root = site.Children.Add("Root", "IIsWebVirtualDir");   //添加虚拟目录对象
     root.Invoke("AppCreate", true); //创建IIS应用程序
     root.Properties["path"][0] = @"D:\IISmanage"; //虚拟目录指向的物理目录
     root.Properties["EnableDirBrowsing"][0] = false;//目录浏览
     root.Properties["AuthAnonymous"][0] = false;
     root.Properties["AccessExecute"][0] = false;   //可执行权限
     root.Properties["AccessRead"][0] = true;
     root.Properties["AccessWrite"][0] = true;
     root.Properties["AccessScript"][0] = true;//纯脚本
     root.Properties["AccessSource"][0] = false;
     root.Properties["FrontPageWeb"][0] = false;
     root.Properties["KeyType"][0] = "IIsWebVirtualDir";
     root.Properties["AppFriendlyName"][0] = siteExplain; //应用程序名
     root.Properties["AppIsolated"][0] = 2;
     root.Properties["DefaultDoc"][0] = defaultDoc; //默认文档
     root.Properties["EnableDefaultDoc"][0] = true; //是否启用默认文档
     root.CommitChanges();
     site.CommitChanges();
     root.Close();
     site.Close();
     de.CommitChanges(); //保存
     site.Invoke("Start", null); //除了在创建过程中置初始状态外,也可在此调用方法改变状态
 }
开发者ID:fsfree,项目名称:dookcms,代码行数:35,代码来源:IISManager.cs

示例10: RemoveUserFromGroup

 public void RemoveUserFromGroup(string userDn, string groupDn)
 {
     DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + groupDn);
     dirEntry.Properties["member"].Remove(userDn);
     dirEntry.CommitChanges();
     dirEntry.Close();
 }
开发者ID:zwolsman,项目名称:proftaak,代码行数:7,代码来源:Authentication.cs

示例11: CreateVirtualDirectory

        static void CreateVirtualDirectory(string parentPath, string name, string homeDirectory, string[] remainingPaths)
        {
            name = name.Trim('/');

            using (var parent = new DirectoryEntry(parentPath))
            {
                string existingChildPath = null;

                foreach (var child in parent.Children.OfType<DirectoryEntry>())
                {
                    if (child.SchemaClassName == "IIsWebVirtualDir" && child.Name.ToLowerInvariant() == name.ToLowerInvariant())
                    {
                        existingChildPath = child.Path;
                    }

                    child.Close();
                }

                if (existingChildPath == null)
                {
                    var child = parent.Children.Add(name.Trim('/'), "IIsWebVirtualDir");
                    child.Properties["Path"][0] = homeDirectory;
                    child.CommitChanges();
                    parent.CommitChanges();
                    existingChildPath = child.Path;
                    child.Close();
                }

                if (remainingPaths.Length > 0)
                {
                    CreateVirtualDirectory(existingChildPath, remainingPaths.First(), homeDirectory, remainingPaths.Skip(1).ToArray());
                }
            }
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:34,代码来源:WebServerSixSupport.cs

示例12: AddUserToGroup

 /// <summary>
 /// Adds a user to a group.
 /// </summary>
 /// <param name="userName">Name of the user.</param>
 /// <param name="groupName">Name of the group.</param>
 public static void AddUserToGroup(string userName, string groupName)
 {
     using (DirectoryEntry groupEntry = new DirectoryEntry("WinNT://./" + groupName + ",Group"))
     {
         groupEntry.Invoke("Add", new object[] { "WinNT://" + userName + ",User" });
         groupEntry.CommitChanges();
     }
 }
开发者ID:mihaibuzgau,项目名称:cf-windows-extensions,代码行数:13,代码来源:WindowsUsersAndGroups.cs

示例13: AddLocalUserToLocalGroup

 //3. Добавление пользователя в группу:
 public static void AddLocalUserToLocalGroup(string userName, string groupName)
 {
     string groupPath = string.Format("WinNT://{0}/{1},group", Environment.MachineName, groupName);
     string userPath = string.Format("WinNT://{0}/{1},user", Environment.MachineName, userName);
     var root = new DirectoryEntry(groupPath);
     root.Invoke("Add", new object[] { userPath });
     root.CommitChanges();
 }
开发者ID:Warlord123,项目名称:RdpTools,代码行数:9,代码来源:RegisterLocalUser.cs

示例14: DisallowOverlappingRotation

		public void DisallowOverlappingRotation(string applicationPoolName)
		{
			using (var applicationPool = new DirectoryEntry(string.Format("{0}/{1}", ApplicationPoolsEntry, applicationPoolName)))
			{
				applicationPool.Properties["DisallowOverlappingRotation"].Value = true;
				applicationPool.CommitChanges();
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:8,代码来源:IIS6Manager.cs

示例15: DeleteApplication

 public void DeleteApplication()
 {
     var directoryEntry =
         new DirectoryEntry(
             String.Concat(new object[] {"IIS://localhost/W3SVC/", _iWebServerID, "/ROOT", _sPath, "/", _sName}));
     directoryEntry.Invoke("AppDelete", new object[0]);
     directoryEntry.CommitChanges();
 }
开发者ID:skitsanos,项目名称:WDK9,代码行数:8,代码来源:IISWebDirectory.cs


注:本文中的System.DirectoryServices.DirectoryEntry.CommitChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。