小编God*_*ter的帖子

错误0x80005000和DirectoryServices

我正在尝试使用.Net中的目录服务运行简单的LDAP查询.

    DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com");
    directoryEntry.AuthenticationType = AuthenticationTypes.Secure;

    DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);

    directorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName={0}))", username);

    var result = directorySearcher.FindOne();
    var resultDirectoryEntry = result.GetDirectoryEntry();

    return resultDirectoryEntry.Properties["msRTCSIP-PrimaryUserAddress"].Value.ToString();
Run Code Online (Sandbox Code Playgroud)

我得到以下例外:

System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
  at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
  at System.DirectoryServices.DirectoryEntry.Bind()
  at System.DirectoryServices.DirectoryEntry.get_AdsObject()
  at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
  at System.DirectoryServices.DirectorySearcher.FindOne()
Run Code Online (Sandbox Code Playgroud)

作为控制台应用中的代码段,这是有效的.但是,当我将其作为WCF服务的一部分运行(在相同的凭据下运行)时,它会抛出上述异常.

有什么建议?

谢谢

.net c# wcf directoryservices active-directory

40
推荐指数
6
解决办法
10万
查看次数

如何让ncurses输出星体平面unicode字符

我有以下一段非常简单的代码,它应该输出(除其他外)三个unicode字符:

/*
 * To build:
 *   gcc -o curses curses.c -lncursesw
 *
 * Expected result: display these chars:
 *   http://www.fileformat.info/info/unicode/char/2603/index.htm  (snowman)
 *   http://www.fileformat.info/info/unicode/char/26c4/index.htm  (snowman without snow)
 *   http://www.fileformat.info/info/unicode/char/1f638/index.htm (grinning cat face with smiling eyes)
 *
 * Looks like ncurses is NOT able to display second and third char
 * (only the first one is OK...)
 */

#include <ncurses.h>
#include <stdio.h>
#include <locale.h>

int
main (int argc, char *argv[])
{
    WINDOW *stdscr;
    char buffer[] = {
        '<',
        0xE2, 0x98, 0x83,       // …
Run Code Online (Sandbox Code Playgroud)

c unicode ncurses utf-8

29
推荐指数
1
解决办法
4666
查看次数

在shell/Perl脚本中保存密码的最佳做法?

我最近不得不放弃我的Perl和shell脚本技能来帮助一些同事.有问题的同事的任务是从内部应用程序提供一些带有大型Oracle数据库后端的报告,他们根本没有这方面的技能.虽然有些人可能会质疑我是否具备这些技能(咧嘴笑),显然有足够的人认为我的意思是我无法摆脱它.

所以对我的问题 - 为了从数据库中提取报告,我的脚本显然必须连接并运行查询.到目前为止,我还没有设法找到一个很好的解决方案,用于存储数据库的用户名和密码,因此它目前在脚本中以明文形式存储.

对于其他人已经编写过的,有没有一个很好的解决方案,可能作为CPAN模块?或者还有其他更好的事情 - 比如将用户/密码组合保存在一个完全独立的文件中,该文件隐藏在文件系统的其他位置?或者我应该对它们进行简单的加密,以避免它们被系统范围的grep从我的脚本中拉出来?

编辑:Oracle数据库位于HP-UX服务器上.
应用程序服务器(运行shell脚本)是Solaris.
将脚本设置为仅由我拥有是不行的,它们必须由多个支持人员可以访问的服务帐户拥有.
这些脚本旨在作为cron作业运行.
我喜欢使用公钥验证,但我不知道如何使用Oracle的方法 - 如果有这样的方法 - 启发我!

oracle bash perl ksh

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

有没有办法用Powershell操作内存中的zip文件内容?

我目前正在尝试编写一个powershell函数,该函数与Lync powershell cmdlet"Export-CsConfiguration -AsBytes"的输出一起使用.使用Lync Cmdlet的隐式Powershell远程处理时,-AsBytes标志是使用Export-CsConfiguration cmdlet的唯一方法,它返回一个Byte数组,如果您使用"Set-Content -Encoding Byte"将其写入磁盘,结果是一个zip文件.

我想知道是否有办法将字节数组的内容扩展为包含在该zip文件中的两个文件,但只能在内存中进行.我真的不想保持zip文件很长时间,因为它经常更改,以及将文件内容写入磁盘只是为了再次直接读取它们所以我可以用未压缩的内容做一些看起来可怕的错误对我来说.

那么有没有做过这样的事情来避免写入磁盘:

$ZipFileBytes = Export-CsConfiguration -AsBytes
# Made up Powershell function follows:
[xml]DocItemSet = Extract-FileFromInMemoryZip -ByteArray $ZipFileBytes -FileInsideZipIWant "DocItemSet.xml"
# Do stuff with XML here
Run Code Online (Sandbox Code Playgroud)

而不是做:

$ZipFileBytes = Export-CsConfiguration -AsBytes | Set-Content -Encoding Byte "CsConfig.zip"
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
[System.IO.Compression.ZipFile]::ExtractToDirectory("CsConfig.zip", "C:\Temp")
[xml]$DocItemSet = New-Object Xml.XmlDocument
$DocItemSet.Load("C:\Temp\DocItemSet.xml")
# Do stuff with XML here
Run Code Online (Sandbox Code Playgroud)

或者我是SOL?

powershell zip

4
推荐指数
1
解决办法
3260
查看次数

标签 统计

.net ×1

active-directory ×1

bash ×1

c ×1

c# ×1

directoryservices ×1

ksh ×1

ncurses ×1

oracle ×1

perl ×1

powershell ×1

unicode ×1

utf-8 ×1

wcf ×1

zip ×1