标签: directoryentry

如何在PHP中迭代非英文文件名

我有一个目录,其中包含几个文件,其中许多文件都有非英文名称.我在Windows 7中使用PHP.

我想使用PHP列出文件名及其内容.

目前我正在使用DirectoryIteratorfile_get_contents.这适用于英文文件名,但不适用于非英文(中文)文件名.

例如,我有像"एकऔरप्रोब्लेम.eml","hello鶨鹙鵨鶣鎹蓥.eml"这样的文件名.

  1. DirectoryIterator 无法使用获取文件名 ->getFilename()
  2. file_get_contents 即使我在其参数中硬编码文件名也无法打开.

我该怎么做?

php directory-listing directoryentry

15
推荐指数
1
解决办法
4642
查看次数

LdapConnection与DirectoryEntry

任何人都可以解释使用LdapConnection/SearchRequest和DirectoryEntry/DirectorySearcher搜索ActiveDirectory中的用户之间的区别.

哪一个最适合与AD互动?

c# active-directory directoryentry

12
推荐指数
1
解决办法
2386
查看次数

如何使用凭据提供DirectoryEntry.Exists?

今天早上我发现了一个很好的方法(DirectoryEntry.Exists),它应该能够检查服务器上是否存在Active Directory对象.所以我试着用一个简单的方法:

if (DirectoryEntry.Exists(path)) {}
Run Code Online (Sandbox Code Playgroud)

当然,它没有任何重载来提供凭据.因为,如果没有提供凭据,我会得到以下异常:

登录失败:未知的用户名或密码错误.(System.DirectoryServices.DirectoryServicesCOMException)

有没有其他选项可以让我在AD服务器上验证我的代码?或者检查对象的存在?

.net c# active-directory directoryentry

10
推荐指数
2
解决办法
1万
查看次数

快速确定用户帐户是否是AD组成员的最佳方法?

我目前有一些代码可以提取组中的用户列表,然后遍历该组以确定给定的帐户是否存在,但似乎应该有更简洁(也许更快)的方法来实现这一点.

此代码(VB.NET)尝试使用组对象的成员属性,但即使用户是该组的成员,它也会返回false.谁能看到我在这里做错了什么?

Dim group As DirectoryEntry =  GetNetworkObject(GroupDomanName, NetworkObjectType.NetworkGroup, GroupName)
Dim user As DirectoryEntry =GetNetworkObject(UserDomainName, NetworkObjectType.NetworkUser, Login)

Return group.Properties("member").Contains(user.Path)
Run Code Online (Sandbox Code Playgroud)

仅供参考:GetNetworkObject调用只返回一个directoryEntry对象,我已经确认正在为组和用户对象返回正确的对象.

ldap adsi active-directory directoryentry

9
推荐指数
1
解决办法
7541
查看次数

使用C#更改AD用户终端服务器属性

我正在使用System.DirectoryServices.DirectoryEntry来创建AD用户,除了一些远程桌面细节属性外,一切正常.

例如:

newUser.Properties["msTSConnectClientDrives"].Value = false;
newUser.Properties["msTSConnectPrinterDrives"].Value = false;
newUser.Properties["msTSDefaultToMainPrinter"].Value = false;
Run Code Online (Sandbox Code Playgroud)

这不会抛出任何异常,所以我猜这些属性在对象中找到但它们没有任何效果.当我进入该用户的属性窗口时,在"环境"选项卡下,仍然会检查这3个复选框.

我错过了这些属性特别的东西吗?

谢谢您帮忙.

编辑:

对不起,我一直很忙,这是一个代码示例:

    private string CreateNewADAccount(string accountName, string accountPassword)
    {
        try
        {
            PrincipalContext context = new PrincipalContext(ContextType.Domain, "SV-LITE", @"LITE\xxxxxxxx", "yyyyyyyy");

            UserPrincipal newUser = new UserPrincipal(context);
            newUser.SamAccountName = accountName;
            newUser.UserPrincipalName = accountName;
            newUser.Name = "LiteUser2015 - " + accountName;
            newUser.DisplayName = "LiteUser2015 - " + accountName;
            newUser.SetPassword(accountPassword);
            newUser.PasswordNeverExpires = true;
            newUser.UserCannotChangePassword = true;

            newUser.Save();

            // Set advanced properties
            if (newUser.GetUnderlyingObjectType() == typeof(DirectoryEntry))
            {
                DirectoryEntry entry = (DirectoryEntry)newUser.GetUnderlyingObject();

                entry.Properties["msTSConnectClientDrives"].Value …
Run Code Online (Sandbox Code Playgroud)

c# properties directoryentry

9
推荐指数
1
解决办法
393
查看次数

如何知道我的DirectoryEntry是否真的连接到我的LDAP目录?

我正在连接到C#中的LDAP目录,所以我使用了DirectoryEntry类.

当您使用地址,登录名和密码执行"new DirectoryEntry"时,它应该连接到LDAP目录.

但是,即使连接不起作用,它也会返回没有问题,并且设置了directoryentry变量.

所以我知道我的连接真的开了吗?现在,我正在使用一个非常非常丑陋的黑客:我放了一个"if(mydirectory.SchemaEntry)",如果没有建立连接会产生异常,因为DirectoryEntry的某些成员,例如SchemaEntry,不是如果连接失败,则设置.但是1:在丑陋的等级2上必须是11/10:在失败之前需要花费很多时间.

那么这样做的好方法是什么?当然,微软必须提供一些东西(即使我使用的是LDAP目录而不是Active Directory)来了解我是否真的已经连接了?

c# ldap active-directory directoryentry

8
推荐指数
2
解决办法
1万
查看次数

给定用户的SID,我如何获得AD DirectoryEntry?

我在windowsPrincipal.getIdentity().getSid()中将用户的SID设置为byte [].如何从SID获取活动目录条目(DirectoryEntry)?

sid directoryentry

7
推荐指数
2
解决办法
1万
查看次数

模拟和DirectoryEntry

我成功冒充用户帐户,但我无法使用模拟帐户绑定到AD并下拉DirectoryEntry.

以下代码输出:

  • 在模仿之前我是:DOMAIN\user
  • 冒充后我是:DOMAIN\admin
  • 错误:C:\ Users\user\ADSI_Impersonation\bin\Debug\ADSI_Impersonation.exe samaccountname:

我的问题似乎与:

如何在ASP.NET中使用System.DirectoryServices命名空间

我正在获得一个主令牌.我知道我需要使用委托在远程计算机上使用模拟令牌.我确认该帐户没有选中"帐户敏感且无法委派"的标志.我还确认本地组策略和域组策略不会阻止委派:

计算机配置\ Windows设置\安全设置\本地策略\用户权限分配\

我错过了什么?

谢谢!

using System;
using System.DirectoryServices;
using System.Security;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;

namespace ADSI_Impersonation
{
    class Program
    {
        [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
            int dwLogonType, int dwLogonProvider, out SafeTokenHandle phToken);

        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        public static extern bool CloseHandle(IntPtr handle);

        static void Main(string[] args)
        {
            const int LOGON32_PROVIDER_DEFAULT = 0; …
Run Code Online (Sandbox Code Playgroud)

c# impersonation directoryentry

7
推荐指数
1
解决办法
9356
查看次数

如何在Active Directory中找到具有GUID(objectGUID)参数的用户

在我的ASP.NET应用程序中,我从Active Directory获取信息.我必须使用GUID信息获取有关用户的信息(例如:a28a6a34dsfdsf57d9e54f945a241),但我不知道如何使用右侧过滤器进行此搜索:/

例如,如果我搜索用户姓氏:

DirectoryEntry Entry = new DirectoryEntry("LDAP://" + "Domain");

            string filter = "(&(objectClass=user)(objectCategory=person)(cn=" + txtBenutzer.Text + "*))";

            DirectorySearcher Searcher = new DirectorySearcher(Entry, filter);

            var q = from s in Searcher.FindAll().OfType<SearchResult>()
                    select new
                    {
                        //GetProperty(s, "objectGUID"),
                        Benutzer = GetProperty(s, "sAMAccountName"),
                        eMail = GetProperty(s, "mail"),
                        Vorname = GetProperty(s, "givenName"),
                        Nachname = GetProperty(s, "sn"),
                        Telefon = GetProperty(s, "telephoneNumber"),
                        UserID = s.GetDirectoryEntry().NativeGuid

                    };

            this.myListView.DataSource = q;
            this.myListView.DataBind();
Run Code Online (Sandbox Code Playgroud)

现在我需要一个带GUID的过滤器,我可以在AD中找到唯一的用户.此搜索的GUID我有一个字符串UserID = Session ["UserID"].toString()

塔拉索夫

c# asp.net ldap active-directory directoryentry

7
推荐指数
1
解决办法
2万
查看次数

在使用托管ODP.NET时,如何从C#查询LDAP以解析Oracle TNS主机名?

继我之前的问题,我设法在Oracle论坛的帮助下回答了自己,我现在有另一个问题,从前一个问题开始(提供给后台).

我希望直接从我的C#代码查询LDAP,以执行Oracle TNS主机名的LDAP查找,以获取连接字符串.这通常存储在tnsnames.ora中,我的组织使用LDAP(通过ldap.ora)使用Active Directory从LDAP服务器解析主机名.

但是,我在我的C#应用​​程序中使用ODP.NET,托管驱动程序测试版(Oracle.ManagedDataAccess.dll),它不支持LDAP,如前面提到的Oracle论坛回复所指出的发行说明中所述.这就是我希望直接从C#查询LDAP的原因.

我在这里找到了一种方法,使用DirectoryEntryDirectorySearcher,但我不知道要把什么作为参数DirectorySearcher.我可以访问ldap.ora,其格式如下:

#LDAP.ORA配置
#由Oracle配置工具生成.
DEFAULT_ADMIN_CONTEXT ="dc = xx,dc = mycompany,dc = com"
DIRECTORY_SERVERS =(ldap_server1.mycompany.com:389:636,ldap_server2.mycompany.com:389:636, ...)DIRECTORY_SERVER_TYPE = OID

但是,如何将其映射到在我的C#代码中设置LDAP查询?

c# oracle tnsnames ldap directoryentry

6
推荐指数
2
解决办法
7508
查看次数