小编KSM*_*KSM的帖子

将PDF流写入响应流

当我尝试从我的asp.net页面运行以下代码时遇到问题.该代码来自另一篇文章(http://stackoverflow.com/questions/5828315/write-pdf-stream-to-response-stream).当Test.pdf文件位于我的本地驱动器中时,单击对话框上的打开按钮时,我无法打开该文件.当单击保存按钮时,文件以"C:\ Downloads"中的myAspPageName.pdf方式尝试,该操作将继续执行,而不会实际保存任何内容.

我确定我做错了什么.谢谢你的帮助.有没有更好的方法做同样的事情?

protected void Page_Load(object sender, EventArgs e) 
{         
    Context.Response.Buffer = false;         
    FileStream inStr = null;         
    byte[] buffer = new byte[1024];         
    long byteCount; inStr = File.OpenRead(@"C:\Downloads\Test.pdf");         
    while ((byteCount = inStr.Read(buffer, 0, buffer.Length)) > 0) 
    {    
        if (Context.Response.IsClientConnected) 
        { 
            Context.Response.ContentType = "application/pdf";
            Context.Response.OutputStream.Write(buffer, 0, buffer.Length);
            Context.Response.Flush();             
        }        
    }     
} 
Run Code Online (Sandbox Code Playgroud)

asp.net

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

解锁用户帐户

我正在尝试设置属性以解锁AD中的用户帐户,我使用以下代码; 问题是de不包含userAccountControl,代码失败.

我可以userAccountControl通过使用获得值,DirectorySearcher但这对我设置属性没有帮助de.有人可以帮帮我吗?提前致谢

String m_Path = "LDAP://" + distinguishedName;

using (DirectoryEntry de = new DirectoryEntry(m_Path))
{
   if (de.Contains("userAccountControl")
   {
      int m_Val  = (int)de.Properties["userAccountControl"][0].Value;
      de.Properties["userAccountControl"].Value = m_Val | 0x0001
      de.CommitChanges;
   }
}
Run Code Online (Sandbox Code Playgroud)

.net c# active-directory

3
推荐指数
1
解决办法
5489
查看次数

如何设置字节数组中的每个位

如何将下一个具有21个字节或168位的字节数组中的每个位设置为零或一个?

byte[] logonHours
Run Code Online (Sandbox Code Playgroud)

非常感谢你

c# bytearray

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

如何使用lockoutTime解锁AD中的用户帐户

我想通过将lockoutTime属性设置为零来解锁AD中的用户帐户.问题是属性的值是System_ComObject.如何将属性的值设置为零?我使用以下代码来获取lockOut的值

DirectoryEntry user = DirectoryEntry(DistinguishedName);

//user.Properties ["lockoutTime"].Value是一个System_Com对象

long fileTicks = LongFromLargeInteger(user.Properties ["lockoutTime"].Value);

private long LongFromLargeInteger(object largeInteger)

{

System.Type type = largeInteger.GetType();

type = largeInteger.GetType();

int highPart =(int)type.InvokeMember("HighPart",BindingFlags.GetProperty,null,largeInteger,null);

int lowPart =(int)type.InvokeMember("LowPart",BindingFlags.GetProperty,null,largeInteger,null

);

return(long)highPart << 32 | (UINT)lowPart;

}

active-directory

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

标签 统计

active-directory ×2

c# ×2

.net ×1

asp.net ×1

bytearray ×1