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


C# DirectoryEntry.Invoke方法代码示例

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


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

示例1: 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

示例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: ExecuteTask

        protected override void ExecuteTask()
        {
            DirectoryEntry newWebsite = FindWebSite(WebsiteName);
            if (newWebsite == null)
            {
                DirectoryEntry w3svc = new DirectoryEntry(IISConstants.IIS_ADSI_ROOT);
                object[] newSiteParams = new object[] { WebsiteName, GetBindings(), WebsitePath.FullName };
                int siteId = (int)w3svc.Invoke("CreateNewSite", newSiteParams);
                newWebsite = FindWebSite(siteId);
            }

            newWebsite.Invoke("SetInfo");
            ApplyProperties(newWebsite, SiteProperties);
            newWebsite.CommitChanges();

            foreach (IISVDirElement vdir in VDirs)
            {
                CreateVDir(newWebsite, vdir);
            }

            foreach (IISWebFileElement webFile in WebFiles)
            {
                CreateWebFile(newWebsite, webFile);
            }
        }
开发者ID:julienblin,项目名称:NAntConsole,代码行数:25,代码来源:IISCreateWebSiteTask.cs

示例4: isAdmin

        public static bool isAdmin(string processName)
        {
            string ProcessOwner = "";
            string ProcessDomain = "";

            System.Management.ObjectQuery x = new System.Management.ObjectQuery("Select * From Win32_Process where Name='" + processName + ".exe" + "'");
            System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(x);
            foreach (System.Management.ManagementObject mo in mos.Get())
            {
                string[] s = new string[2];
                mo.InvokeMethod("GetOwner", (object[])s);
                ProcessOwner = s[0].ToString();
                ProcessDomain = s[1].ToString();
                break;
            }

            string userPath = ProcessDomain + "/" + ProcessOwner;

            using (DirectoryEntry groupEntry = new DirectoryEntry("WinNT://./Administrators,group"))
            {
                foreach (object member in (IEnumerable)groupEntry.Invoke("Members"))
                {
                    using (DirectoryEntry memberEntry = new DirectoryEntry(member))
                    {
                        Console.WriteLine(memberEntry.Path);
                        if (memberEntry.Path.Contains(userPath))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
开发者ID:hfenigma,项目名称:d3adventure,代码行数:34,代码来源:ProcessTools.cs

示例5: 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

示例6: Delete

 public void Delete(string RootWeb, string PhysicalDirectory, string VirtualDirectory, out string Error)
 {
     Error = "";
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         if (this.CheckIfExists(RootWeb, VirtualDirectory))
         {
             DirectoryEntry entry = new DirectoryEntry(RootWeb);
             new DirectoryEntry(RootWeb + "/" + VirtualDirectory).Invoke("AppDelete", null);
             object[] args = new object[] { "IIsWebVirtualDir", VirtualDirectory };
             entry.Invoke("Delete", args);
             Directory.Delete(PhysicalDirectory, true);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(exception.ToString());
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:IISVirtualRoot.cs

示例7: 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

示例8: RecycleApplicationPool

        private static void RecycleApplicationPool(string appPoolId)
        {
            string appPoolPath = "IIS://localhost/W3SVC/AppPools/" + appPoolId;

            var appPoolEntry = new DirectoryEntry(appPoolPath);
            appPoolEntry.Invoke("Recycle");
        }
开发者ID:haimon74,项目名称:Easy-Fixup,代码行数:7,代码来源:ApplicationPoolRecycle.cs

示例9: CreateFtpServerVirtualDirectory

        public void CreateFtpServerVirtualDirectory(int iFtpSiteID, string sVirtualDirectoryName, string sPath,
                                                    bool bCanRead, bool bCanWrite, bool isRoot)
        {
            DirectoryEntry directoryEntry1;

            DirectoryEntry directoryEntry2;

            if (!isRoot)
            {
                directoryEntry1 = new DirectoryEntry(String.Concat("IIS://localhost/MSFTPSVC/", iFtpSiteID, "/ROOT"));
                var locals = new object[] {"IISFtpVirtualDir", sVirtualDirectoryName};
                directoryEntry2 = (DirectoryEntry) directoryEntry1.Invoke("Create", locals);
            }
            else
            {
                directoryEntry1 = new DirectoryEntry(String.Concat("IIS://localhost/MSFTPSVC/", iFtpSiteID));
                var locals = new object[] {"IISFtpVirtualDir", "ROOT"};
                directoryEntry2 = (DirectoryEntry) directoryEntry1.Invoke("Create", locals);
            }
            directoryEntry2.Properties["Path"][0] = sPath;
            int i = 0;
            if (bCanRead)
            {
                i++;
            }
            if (bCanWrite)
            {
                i += 2;
            }
            directoryEntry2.Properties["AccessFlags"][0] = i;
            directoryEntry2.CommitChanges();
            directoryEntry1.Invoke("SetInfo", new object[0]);
            directoryEntry1.CommitChanges();
            directoryEntry1.Dispose();
        }
开发者ID:skitsanos,项目名称:WDK9,代码行数:35,代码来源:IISManager.cs

示例10: 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

示例11: BackupFarm

        public void BackupFarm(SPFarm farm, bool prepare)
        {
            if (prepare)
                PrepareSystem();

            if (_includeIis)
            {
                // Export the IIS settings.
                string iisBakPath = Path.Combine(_path, "iis_full.bak");
                if (_overwrite && File.Exists(iisBakPath))
                    File.Delete(iisBakPath);
                if (!_overwrite && File.Exists(iisBakPath))
                    throw new SPException(
                        string.Format("The IIS backup file '{0}' already exists - specify '-overwrite' to replace the file.", iisBakPath));

                //Utilities.RunCommand("cscript", string.Format("{0}\\iiscnfg.vbs /export /f \"{1}\" /inherited /children /sp /lm", Environment.SystemDirectory, iisBakPath), false);
                using (DirectoryEntry de = new DirectoryEntry("IIS://localhost"))
                {
                    Logger.Write("Exporting full IIS settings....");
                    string decryptionPwd = string.Empty;
                    de.Invoke("Export", new object[] { decryptionPwd, iisBakPath, "/lm", FLAG_EXPORT_INHERITED_SETTINGS });
                }
            }
            SPEnumerator enumerator = new SPEnumerator(farm);
            InitiateEnumerator(enumerator);
        }
开发者ID:GSoft-SharePoint,项目名称:PowerShell-SPCmdlets,代码行数:26,代码来源:BackupSites.cs

示例12: ProcessRecord

        protected override void ProcessRecord()
        {
            string _path = "IIS://" + _serverName + "/W3SVC/AppPools/" + _appPoolName;

            try
            {
                DirectoryEntry _w3svc = new DirectoryEntry(_path);
                _w3svc.Invoke("Recycle", null);
                WriteObject(_path + " was recycled");

            }
            catch (System.Runtime.InteropServices.COMException _ex)
            {
                _attempts++;

                if (_attempts < 4)
                {
                    this.ProcessRecord();
                }
                else
                {
                    WriteError(new ErrorRecord(_ex, "3AppPoolRecycleFailure", ErrorCategory.ResourceUnavailable, (object)_path));
                    throw (_ex);
                }
            }
            catch (Exception ex)
            {
                throw (ex);

            }
        }
开发者ID:hopenbr,项目名称:HopDev,代码行数:31,代码来源:Recyle-AppPool.cs

示例13: RecyclePool

 public static void RecyclePool()
 {
     using (var pool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools/RequestReduce"))
     {
         pool.Invoke("Recycle", null);
     }
     Thread.Sleep(2000);
 }
开发者ID:colintho,项目名称:RequestReduce,代码行数:8,代码来源:IntegrationFactHelper.cs

示例14: 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

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