2013-04-17 35 views
2

我在azure WebRole 中託管WCF 4.5服務,我使用Azure ACS服務標識來管理我的wcf用戶(活動身份驗證)。 這種模式被接受我,因爲我們的用戶如何管理ACS服務標識

的數量有限,現在我想知道我怎樣才能管理(創建/讀取/更新/刪除)ACS服務標識編程通過C#代碼。

回答

5

看看ACS Management Service API其中有ServiceIdentity管理。

管理端點位於:
https://NAMESPACE.accesscontrol.windows.net/v2/mgmt/service

您可以利用此ACS管理服務來創建新的ServiceIdentities

string name = "SampleServiceIdentity"; 
string password = "SampleServiceIdentityPassword"; 
ServiceIdentity sid = new ServiceIdentity() 
{ 
    Name = name 
}; 

DateTime startDate, endDate; 
startDate = DateTime.UtcNow; 
endDate = DateTime.MaxValue; 

ServiceIdentityKey key = new ServiceIdentityKey() 
{ 
    EndDate = endDate.ToUniversalTime(), 
    StartDate = startDate.ToUniversalTime(), 
    Type = "Password", 
    Usage = "Password", 
    Value = Encoding.UTF8.GetBytes(password), 
    DisplayName = String.Format(CultureInfo.InvariantCulture, "{0} key for {1}", "Password", name) 
}; 

svc.AddToServiceIdentities(sid); 
svc.AddRelatedObject(
    sid, 
    "ServiceIdentityKeys", 
    key); 


svc.SaveChanges(SaveChangesOptions.Batch); 

這個例子來自MSDN - How to: Use ACS Management Service to Configure Service Identies

+0

,我不知道如何使用它! –

+0

ACS管理服務交互實際上是一系列步驟 - 如果您按照[MSDN文章參考](http://msdn.microsoft.com/en-us/library/windowsazure/hh135148.aspx)它應該回答您的HOW 。您需要使用端點進行身份驗證,然後才能使用您的身份執行CRUD操作。 – SliverNinja

1

一個簡單的如何演示稱爲調用ACS管理服務編程here