本文整理汇总了C#中System.DirectoryServices.DirectoryEntry.RefreshCache方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.RefreshCache方法的具体用法?C# DirectoryEntry.RefreshCache怎么用?C# DirectoryEntry.RefreshCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DirectoryServices.DirectoryEntry
的用法示例。
在下文中一共展示了DirectoryEntry.RefreshCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IIsSite
public IIsSite(DirectoryEntry SiteEntry, DirectoryEntry RootEntry)
{
if (SiteEntry.SchemaClassName == IIsHelper.SiteSchemaClassName & RootEntry.SchemaClassName == IIsHelper.VirtualDirectorySchemaClassName)
{
_SiteEntry = SiteEntry;
_SiteEntry.RefreshCache();
_RootEntry = RootEntry;
_RootEntry.RefreshCache();
}
else
{
if (SiteEntry.SchemaClassName != IIsHelper.SiteSchemaClassName)
{
IIsHelper.ConstructorEx(IIsHelper.SiteSchemaClassName);
}
if (RootEntry.SchemaClassName != IIsHelper.VirtualDirectorySchemaClassName)
{
IIsHelper.ConstructorEx(IIsHelper.VirtualDirectorySchemaClassName);
}
}
}
示例2: GetProperty
public static object GetProperty(string PropertyName, DirectoryEntry DirEntry)
{
try
{
DirEntry.RefreshCache();
if ((DirEntry.Properties[PropertyName].Value != null))
{
return DirEntry.Properties[PropertyName].Value;
}
else
{
return null;
}
}
catch (Exception ex)
{
GetPropertyEx(PropertyName, ex);
return null;
}
}
示例3: GetADGroups
/// <summary>
/// 取用户所对应的用户组
/// </summary>
/// <param name="userName">用户名称</param>
/// <param name="domain">域</param>
/// <param name="adusername">登陆用户</param>
/// <param name="adpassword">登陆密码</param>
/// <returns></returns>
public static List<string> GetADGroups(string userName,string domain,string adusername,string adpassword)
{
List<string> groups = new List<string>();
try
{
var entry = new DirectoryEntry(string.Format("LDAP://{0}", domain), adusername, adpassword);
entry.RefreshCache();
DirectorySearcher search = new DirectorySearcher(entry);
search.PropertiesToLoad.Add("memberof");
search.Filter = string.Format("sAMAccountName={0}", userName);
SearchResult result = search.FindOne();
if (result != null)
{
ResultPropertyValueCollection c = result.Properties["memberof"];
foreach (var a in c)
{
string temp = a.ToString();
Match match = Regex.Match(temp, @"CN=\s*(?<g>\w*)\s*.");
groups.Add(match.Groups["g"].Value);
}
}
}
catch
{
}
return groups;
}
示例4: IIsService
public IIsService()
{
String ServiceName = FirstServiceName();
String AppPoolsName = FirstAppPoolsName();
if (ServiceName == string.Empty)
{
throw new Exception("No IIS Web Service Metabase entry found on this machine.");
}
else
{
_ServiceEntry = new DirectoryEntry(IIsHelper.IIsProviderPath + "/" + ServiceName);
_ServiceEntry.RefreshCache();
}
if (AppPoolsName == string.Empty)
{
throw new Exception("No Application Pools Metabase entry found on this machine.");
}
else
{
_ApplicationPoolsEntry = new DirectoryEntry(IIsHelper.IIsProviderPath + "/" + ServiceName + "/" + AppPoolsName);
_ApplicationPoolsEntry.RefreshCache();
}
}
示例5: ValidateUserThroughAD
public static bool ValidateUserThroughAD(string empNo, string password)
{
string msg = string.Empty;
try
{
const string ldapPath = "LDAP://192.168.1.1/CN=glpi,CN=users,DC=powergrid,DC=net";
var userIo = new DirectoryEntry(ldapPath);
if (IsUserInAD(empNo, ldapPath, userIo, password))
{
userIo.Username = empNo;
userIo.Password = password;
userIo.RefreshCache();
msg = "VALIDATED";
}
else
{
msg = "VALIDATED";
}
}
catch (Exception)
{
msg = "WRONG";
}
return msg == "VALIDATED";
}
示例6: LoadADGroups
/// <summary>
/// populate all active directory groups in to list box
/// </summary>
private void LoadADGroups()
{
using (var context = new PrincipalContext(ContextType.Domain, Form1._Domain, Form1._AdminUser, Form1._Password))
{
DirectoryEntry objADAM = default(DirectoryEntry);
DirectoryEntry objGroupEntry = default(DirectoryEntry);
DirectorySearcher objSearchADAM = default(DirectorySearcher);
SearchResultCollection objSearchResults = default(SearchResultCollection);
string strPath = null;
List<string> result = new List<string>();
strPath = "LDAP://" + Form1._Domain;
try
{
objADAM = new DirectoryEntry(strPath, Form1._AdminUser, Form1._Password);
objADAM.RefreshCache();
}
catch (Exception ex)
{
Form1.myForm.lblMessage.Text = ex.Message;
Form1.myForm.lblMessage.Show();
}
try
{
objSearchADAM = new DirectorySearcher(objADAM);
objSearchADAM.Filter = "(&(objectClass=group))";
objSearchADAM.SearchScope = SearchScope.Subtree;
objSearchResults = objSearchADAM.FindAll();
}
catch (Exception)
{
throw;
}
try
{
if (objSearchResults.Count != 0)
{
foreach (SearchResult objResult in objSearchResults)
{
objGroupEntry = objResult.GetDirectoryEntry();
result.Add(objGroupEntry.Name.Replace("CN=",""));
}
Form1.myForm.lbGroups.DataSource = result;
Form1.myForm.lbGroups.SelectedIndex = -1;
Form1.myForm.lbUpdateADGroups.DataSource = result;
Form1.myForm.lbUpdateADGroups.SelectedIndex = -1;
}
}
catch (Exception ex)
{
Form1.myForm.lblMessage.Text = ex.Message;
Form1.myForm.lblMessage.Show();
}
}
}
示例7: GetIis6AppPools
public static IList<string> GetIis6AppPools()
{
List<string> pools = new List<string>();
using (DirectoryEntry poolRoot = new DirectoryEntry("IIS://localhost/W3SVC/AppPools"))
{
poolRoot.RefreshCache();
pools.AddRange(poolRoot.Children.Cast<DirectoryEntry>().Select(p => p.Name));
}
return pools;
}
示例8: GetAppPools
public IList<string> GetAppPools()
{
var pools = new List<string>();
using (var poolRoot = new DirectoryEntry(ApplicationPoolsEntry))
{
poolRoot.RefreshCache();
pools.AddRange(poolRoot.Children.Cast<DirectoryEntry>().Select(p => p.Name));
}
return pools;
}
示例9: IIsFile
public IIsFile(DirectoryEntry FileEntry)
{
if (FileEntry.SchemaClassName == IIsHelper.FileSchemaClassName)
{
_FileEntry = FileEntry;
_FileEntry.RefreshCache();
}
else
{
IIsHelper.ConstructorEx(IIsHelper.FileSchemaClassName);
}
}
示例10: GetIis6Sites
public static IList<IisWebSite> GetIis6Sites()
{
List<IisWebSite> sites = new List<IisWebSite>();
using (DirectoryEntry iisRoot = new DirectoryEntry("IIS://localhost/W3SVC"))
{
iisRoot.RefreshCache();
sites.AddRange(iisRoot.Children.Cast<DirectoryEntry>().
Where(w => w.SchemaClassName.ToLower(CultureInfo.InvariantCulture) == "iiswebserver").
Select(w => new IisWebSite(w.Name, w.Properties["ServerComment"].Value.ToString())));
}
return sites;
}
示例11: TryAuthenticate
/// <summary>
/// 验证AD用户是否登陆成功
/// </summary>
/// <param name="domain">域名称</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns>返回登陆状态</returns>
public static bool TryAuthenticate(string domain, string username, string password)
{
bool isLogin = false;
try
{
DirectoryEntry entry = new DirectoryEntry(string.Format("LDAP://{0}", domain), username, password);
entry.RefreshCache();
isLogin = true;
}
catch
{
isLogin = false;
}
return isLogin;
}
示例12: TryAuthenticate
/// <summary>
/// 验证AD用户是否登陆成功
/// </summary>
/// <param name="domain">域名称</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns>返回登陆状态</returns>
public bool TryAuthenticate(string Account, string Password)
{
bool isLogin = false;
try
{
DirectoryEntry entry = new DirectoryEntry(LDAPPath + Domain, Account, Password);
entry.RefreshCache();
isLogin = true;
}
catch
{
isLogin = false;
}
return isLogin;
}
示例13: RetrieveDirectoryEntry
public ADDirectoryEntry RetrieveDirectoryEntry(string DistinguishedName, string[] LoadProperties = null)
{
if (string.IsNullOrWhiteSpace(DistinguishedName))
throw new ArgumentNullException("DistinguishedName");
if (!DistinguishedName.EndsWith(this.Domain.DistinguishedName, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(string.Format("The Distinguished Name ({0}) isn't a member of this domain [{1}]", DistinguishedName, this.Domain.Name), "DistinguishedName");
var entry = new DirectoryEntry(string.Format(LdapPathTemplate, this.Name, ADHelpers.EscapeDistinguishedName(DistinguishedName)));
if (LoadProperties != null)
entry.RefreshCache(LoadProperties);
return new ADDirectoryEntry(this.Domain, this, entry);
}
示例14: DelSite
public static string DelSite(int siteidon)
{
int SiteID = siteidon;
//if (SiteID == null) return "error:该站点不存在!!";
DirectoryEntry deRoot = new DirectoryEntry("IIS://localhost/W3SVC");
DirectoryEntry deVDir = new DirectoryEntry();
deRoot.RefreshCache();
deVDir = deRoot.Children.Find("huke8huke", "IIsVirtualDir");
deRoot.Children.Remove(deVDir);
//deVDir.Invoke("AppDelete",true);
deRoot.CommitChanges();
deRoot.Close();
return "successful:删除站点成功!";
}
示例15: IIsDirectory
public IIsDirectory(DirectoryEntry DirEntry)
{
if (DirEntry.SchemaClassName == IIsHelper.DirectorySchemaClassName)
{
_DirectoryEntry = DirEntry;
_DirectoryEntry.RefreshCache();
}
else
{
IIsHelper.ConstructorEx(IIsHelper.DirectorySchemaClassName);
}
}