小编xte*_*408的帖子

如何在使用WCF服务的WPF应用程序中集成LDAP

我将首先描述我的应用程序如何在没有LDAP的情况下工作.我有WPF应用程序,它使用WCF服务(身份验证窗口UserName取决于用户选择).此服务允许与数据库通信.

我向用户显示"登录屏幕",以便允许他设置"用户名"和"密码",然后应用程序连接到服务并使用检查UserName和Password是否存在于数据库中的功能.(见下面的img) 在此输入图像描述

现在,我还需要集成LDAP以根据现有系统验证用户帐户,而不必创建另一个登录帐户.

我对LDAP一无所知,对许多事情感到困惑.请原谅可能使用错误的术语.

我用谷歌搜索,但我仍然没有很多问题的答案.

1-我的数据库表"User"中存在的用户与我应该在LDAP中创建的配置文件之间的关系是什么?

2-我应该做些什么来允许用户从LDAP访问我的应用程序并使用我服务的所有功能?

3-我是否应该像我今天在我的应用程序中使用的其他身份验证类型("Windows"和"UserName")那样拥有服务类型"LDAP"?

4-如果我想更新上图所示的应用程序架构,我应该在哪里添加LDAP?

c# authentication wpf wcf ldap

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

使用 CryptoPP::HexDecoder()

我第一次玩 Cryptopp,我找到了一个编码为十六进制的例子......一切都很好。现在我想将生成的 std::string 解码为原始字符串,但我得到的只是空字符串。

#include "stdafx.h"

#include "../cryptopp562/sha.h"
#include "../cryptopp562/filters.h"
#include "../cryptopp562/hex.h"
#include <iostream>
#include <string>

int main() {
    CryptoPP::SHA1 sha1;
    std::string source = "Panawara";  
    std::string hash = "";
    std::string original= "" ;

    CryptoPP::StringSource(source, true, new CryptoPP::HashFilter(sha1, new CryptoPP::HexEncoder(new CryptoPP::StringSink(hash))));
    std::cout << hash;
    std::cout << "\n";

    CryptoPP::StringSource (hash, new CryptoPP::HexDecoder(new CryptoPP::StringSink(original)));  // the result is always empty String
    std::cout << original;
    std::cout << "\n";

    system("pause");
}
Run Code Online (Sandbox Code Playgroud)

c++ encryption hex crypto++ visual-c++

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

如何在Android中的微调器中居中文本

我的LinearLayour中有一个Spinner.

我试图在微调器中居中文本:

在此输入图像描述

这是我对该元素的XML:

 <Spinner
    android:id="@+id/project_Spinner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="50dp"
    android:layout_marginLeft="50dp"
    android:padding="1dip"


    android:prompt="@string/spinner_title"
/>
Run Code Online (Sandbox Code Playgroud)

活动中微调器的声明:

// Creating adapter for spinner
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, NomProjets);

    // Drop down layout style - list view with radio button
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // attaching data adapter to spinner
    spinner.setAdapter(dataAdapter);
Run Code Online (Sandbox Code Playgroud)

谢谢,

android

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

如何将CryptoPP :: Integer转换为char*

我想将myVar转换CryptoPP:Integerchar*或转换为String:代码如下:

CryptoPP::Integer myVar = pubKey.ApplyFunction(m);
std::cout << "result: " << std::hex << myVar<< std::endl;
Run Code Online (Sandbox Code Playgroud)

我一直在互联网上寻找转换CryptoPP:Integer,char*但我找不到运气.所以,无论是转换CryptoPP:Integer到所有人都是一个真正的问题char*,要么我CryptoPP:Integer在C++中都不太了解类型.

有谁可以帮助我吗?

c++ crypto++ visual-c++

3
推荐指数
2
解决办法
2410
查看次数

C++ istream :: read导致未定义的行为

我使用以下代码将n字符从二进制文件复制到char*变量:

 std::ifstream is ("write.abc", std::ifstream::binary);
  if (is) {
    // get length of file:
    is.seekg (0, is.end);
    int length = is.tellg();
    is.seekg (0, is.beg);

    char * buffer = new char [length];

    std::cout << "Reading " << length << " characters... ";
    // read data as a block:
    is.read (buffer,length);
    std::cout << "length of buffer: "<<strlen(buffer) <<endl;
    std::cout << "Content of buffer: "<<buffer <<endl;
.......
Run Code Online (Sandbox Code Playgroud)

我的文件内容:

在此输入图像描述

这是编译的结果: 在此输入图像描述

我的问题如下:我等着:

缓冲长度:13

缓冲内容:abcdefghjklmn

有人可以帮我解释一下结果吗?

c++ binaryfiles binary-data

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

字符串到SecByteBlock转换

我目前正在用C++编写blowfish加密/解密程序(使用crypto ++).

我真的没有在谷歌找到满意的答案.我正在尝试将一个SecByteBlock的密钥作为字符串发送,然后在另一部分接收为字符串,然后需要重新获得SecByteBlock.

是否可以转换字符串< - > SecByteBlock

我可以做一些更好的事情将密钥从一个功能发送到另一个功能吗

提前感谢您的帮助.

我使用的代码如下:

int main(int argc, char* argv[])
{
    AutoSeededRandomPool prng;
    SecByteBlock key(Blowfish::DEFAULT_KEYLENGTH);
    prng.GenerateBlock(key, key.size());

    byte iv[Blowfish::BLOCKSIZE];
    prng.GenerateBlock(iv, sizeof(iv));
    BLOCK test = ReadStaticBlocks("testBin.dat");

    string plain=test.bl1 ;
    string cipher, encoded, recovered;

    /*********************************\
    \*********************************/

    // Pretty print key
    encoded.clear();
    StringSource ss1(key, key.size(), true,
        new HexEncoder(
            new StringSink(encoded)
        ) // HexEncoder
    ); // StringSource
    cout << "key: " << encoded << endl;

    // Pretty print iv
    encoded.clear();
    StringSource ss2(iv, sizeof(iv), true,
        new HexEncoder(
            new StringSink(encoded)
        ) …
Run Code Online (Sandbox Code Playgroud)

c++ string converters crypto++

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

WPF MVVM使用View Model中的代码C#为TreeView添加动态上下文菜单

我在这篇着名的文章的帮助下使用HierarchicalDataTemplate创建了一个TreeView.

我的树视图中的每个节点都有不同的contextMenu.所以我为treeView创建了一个属性,它为我返回所选节点的对象.然后我使用下面的代码来显示我的ContextMenu.但contextMenu总是空的.

<view:MyTreeView ItemsSource="{Binding MyNode}" 
SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}" >
    <TreeView.Resources>
      <ContextMenu x:Key="MyContextMenu" ItemsSource="{Binding ContextMenuItem}"/>
       <DataTemplate DataType="{x:Type local:ChildViewModel}">
         <StackPanel Orientation="Horizontal" ContextMenu="{StaticResource MyContextMenu}">
//...
         </StackPanel>
       </DataTemplate>
   </TreeView.Resources>
</view:MyTreeView>
Run Code Online (Sandbox Code Playgroud)

PrincipalViewModel :(与ChildViewModel无关)

private ICommand _editMapCommand;

    public ICommand EditMapCommand
    {
        get
        {
            return _editMapCommand;
        }
        set
        {
            SetProperty(ref _editMapCommand, value, () => EditMapCommand);
            OnPropertyChanged("EditMapCommand");

        }
    }

    private ICommand _removeMapCommand;

    public ICommand RemoveMapCommand
    {
        get
        {
            return _removeMapCommand;
        }
        set
        {
            SetProperty(ref _removeMapCommand, value, () => RemoveMapCommand);
            OnPropertyChanged("RemoveMapCommand");

        }
    }
 private ObservableCollection<MenuItem> _contextMenuMap; …
Run Code Online (Sandbox Code Playgroud)

wpf treeview xaml contextmenu mvvm

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