For some accounts of my company I can't get the email signature. I use the following code to retrieve signatures:
OWAConfig = UserConfiguration.Bind(_service, "OWA.UserOptions", WellKnownFolderName.Root, UserConfigurationProperties.Dictionary);
Normally it works fine but for some accounts, it throws :
The specified object was not found in the store., The configuration object was not found. Name = OWA.UserOptions.
That error will occur for accounts where they have never logged onto OWA before.
The UserConfiguration object won't exist for those accounts and you won't be able to bind to it in code.
You can check for the UserConfiguration object first and then create it, if it doesn't exist:
SearchFilter sf = new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Configuration.OWA.UserOptions");
ItemView iv = new ItemView(1);
iv.Traversal = ItemTraversal.Associated;
FindItemsResults<Item> fiResults = Root.FindItems(sf, iv);
UserConfiguration OWAConfig =null;
if (fiResults.Items.Count == 0)
{
OWAConfig = new UserConfiguration(service);
OWAConfig.Save("OWA.UserOptions", Root.ParentFolderId);
}
Note: Creating a new UserConfiguration object may cause issues as it doesn't set the first time OWA logon settings, Regional settings etc.
You will need to test the affected accounts for this and rectify them accordingly.
Related
I am following the docs on how to set up a backend with firestore:
https://firebase.google.com/docs/firestore/quickstart?authuser=0#c_1
I already set up a service account, genereted a key file and fed that into the code on my end. The connection works and I set the right permission (owner) to be able to read the bucket list.
But as soon as I try the first line of code from the tutorial:
FirestoreDb db = FirestoreDb.Create(project);
Console.WriteLine("Created Cloud Firestore client with project ID: {0}", project);
The execution dies. It doesnt lead to an error message, it doesnt run into a catch block with an exception. It just doesnt continue after the Create(project) part.
I noticed however, that the created datebase on the firebase console and the service account dont seem to be connected yet. Also, I dont know what to put for "project". I tried the project Id from the service account (with which i can do listbuckets) but this doesnt seem to work.
In the docs it does not state anything about what else to do.
Can you guys give me a hint maybe?
Thank you
EDIT:
LONGER CODE EXCEPT:
var credential = GoogleCredential.FromFile("/Users/juliustolksdorf/Projects/Interior Circle/keys/interiorcircle-4f70f209e160.json");
var storage = StorageClient.Create(credential);
// Make an authenticated API request.
var buckets = storage.ListBuckets("interiorcircle");
foreach (var bucket in buckets)
{
Console.WriteLine(bucket.Name);
}
var db = FirestoreDb.Create("interiorcircle");
DocumentReference docRef = db.Collection("users").Document("alovelace");
Dictionary<string, object> user = new Dictionary<string, object>
{
{ "First", "Ada" },
{ "Last", "Lovelace" },
{ "Born", 1815 }
};
await docRef.SetAsync(user);
}
catch(Exception e)
{
DisplayAlert("hi", e.ToString(), "ok");
}
List buckets works, so the key is set correctly, but as soon as I try to do the create DB it fails.
You should refer to the Firestore .NET Client Documentation.
In order to connect, you should pass the projectId to FirestoreDb.Create and you should set and environment variable called GOOGLE_APPLICATION_CREDENTIALS which contains the path to your service account JSON file.
Edit:
You can also explicitly pass the credential to FirestoreDb, by using:
FirestoreDb db = new FirestoreDbBuilder { ProjectId = projectId, Credential = credential }.Build();
I want to add members inside specific shared drive (Team drive).
i have tried with inserting permission request as below:
var listPermisssion = new List<TeamDrivePermissionDetailsData>() { };
TeamDrivePermissionDetailsData permission = new TeamDrivePermissionDetailsData()
{
Role = role,
TeamDrivePermissionType ="member" ,
};
listPermisssion.Add(permission);
Permission tdrivePermission = new Permission();
tdrivePermission.EmailAddress = who;
tdrivePermission.TeamDrivePermissionDetails = listPermisssion;
var requestPermission = service.Permissions.Create(tdrivePermission, sharedDriveId);
requestPermission.Execute();
i got this error :
Error:'Google.Apis.Requests.RequestError
The permission role field is required. [400]
thnks for the help.
The method Permissions:create requires the specification of role and type as described in the documentation
member is not a valid option for type - it should be one of the following options:
user
group
domain
anyone
role expects one of the following options:
owner
organizer
fileOrganizer
writer
commenter
reader
When I access X509Certificate2.PublicKey or X509Certificate2.PrivateKey initialized from an object that was generated with BouncyCastle, I'm getting my domain account locked out (if I do it multiple times). It happens if I run the program on behalf of a local account with the same name but different password. Here is the code:
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System.IO;
using System.Security.Cryptography.X509Certificates;
namespace TestCertificateConversion
{
class Program
{
static void Main(string[] args)
{
var certString = GetCertificateString();
var textReader = new StringReader(certString);
var pemReader = new PemReader(textReader);
var bcCert = pemReader.ReadObject() as Org.BouncyCastle.X509.X509Certificate;
var netCert = DotNetUtilities.ToX509Certificate(bcCert);
var netCert2 = new X509Certificate2(netCert);
var publicKey = netCert2.PublicKey; // this locks out domain account
}
private static string GetCertificateString()
{
return #"-----BEGIN CERTIFICATE-----
MIICvDCCAaSgAwIBAgIQANDHl0sFjYUG3j76dYTadzANBgkqhkiG9w0BAQsFADAQ
MQ4wDAYDVQQDDAVwYWNlbTAgFw0xNjAxMDExMjQ4MzdaGA8yMjAwMDEwMTIyNTg0
N1owEDEOMAwGA1UEAwwFcGFjZW0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQC5AKAkYnerRUmeAX0Z+aZsX39LXTVZiUd8U6waw7Hzd9E0YA50tHWizfEI
w7IBZwXS0aiXwHqJvrslc3NNs0grwu/iYQl+FGdudKmgXVE7Riu0uFAHo6eFr0dO
o0IP3LS+dPSWarXEBLbymaXRiPJDyHLefvslcSM9UQ2BHOe7dnHh9K1h+XMKTw3Z
/3szAyABBX9hsJU/mc9XjrMNXHJXALSxTfLIPzDrfh+aJtlopWpnb6vQcXwKksyk
4hyVUfw1klhglJgN0LgBGU7Ps3oxCbOqns7fB+tzkBV1E5Q97otgvMR14qLZgc8k
NQrdMl57GaWQJl6mAP1NR1gZt2f1AgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJ
KoZIhvcNAQELBQADggEBAAEz3vJOfqao9QXPWSz8YCjbWG1FeVG0NdYpd422dC2V
Vrzlo5zrkRv5XPhBOY3o81OhUe7iByiiM9suYfXLNxxd29TBGB5amO8Yv1ZX0hS/
zvVF6QS0+zZvOiujVhfHGiJxKypqgaigI6NM80ZDKPzsRPwFLIJiZYwQ7eQUlrpt
WGgFkZC23/mSOkY6VMmO5zugeMoiXRyFq33uWLlaAr+zJtRh1IPRmkA1lJv0bkC1
SslO0oSDoT2lcvZkQ5odFKX5i1z7T/wioQqG62i8nsDSz+iZOqUyDx7bL8fIEHog
qgwizgr2aAPLO/VQKU9pRTyRNFl/GL5bi7w8NN+rLxE=
-----END CERTIFICATE-----";
}
}
}
I'm not sure what I'm doing wrong, are there any security settings I might need to change to prevent it from locking out domain accounts?
Can you check and confirm if the service account is coming in this format
I checked the .net source code and found what causes an authentication problem in X509Certificate2.PublicKey. It is a creation of a new OID object:
public PublicKey PublicKey {
[SecuritySafeCritical]
get {
if (m_safeCertContext.IsInvalid)
throw new CryptographicException(SR.GetString(SR.Cryptography_InvalidHandle), "m_safeCertContext");
if (m_publicKey == null) {
string friendlyName = this.GetKeyAlgorithm();
byte[] parameters = this.GetKeyAlgorithmParameters();
byte[] keyValue = this.GetPublicKey();
Oid oid = new Oid(friendlyName, OidGroup.PublicKeyAlgorithm, true); // this line
m_publicKey = new PublicKey(oid, new AsnEncodedData(oid, parameters), new AsnEncodedData(oid, keyValue));
}
return m_publicKey;
}
}
The OID constructor is called with lookupFriendlyName set to 'true', which leads to FindOidInfoWithFallback function:
// Try to find OID info within a specific group, and if that doesn't work fall back to all
// groups for compatibility with previous frameworks
internal static string FindOidInfoWithFallback(uint key, string value, OidGroup group)
{
string info = FindOidInfo(key, value, group);
// If we couldn't find it in the requested group, then try again in all groups
if (info == null && group != OidGroup.All)
{
info = FindOidInfo(key, value, OidGroup.All);
}
return info;
}
The first FindOidInfo returns null and then it is called second time with OidGroup.All. Eventually it results in cryptAPI call:
CAPIMethods.CryptFindOIDInfo(dwKeyType, pvKey, dwGroupId);
From documentation:
The CryptFindOIDInfo function performs a lookup in the active
directory to retrieve the friendly names of OIDs under the following
conditions:
The key type in the dwKeyType parameter is set to CRYPT_OID_INFO_OID_KEY or CRYPT_OID_INFO_NAME_KEY.
No group identifier is specified in the dwGroupId parameter or the GroupID refers to EKU OIDs, policy OIDs or template OIDs.
It then attempts to authentication with local user account and as a result I'm getting my domain account locked. From the comments to the code I see that the second FindOidInfo call was added for compatibility with older frameworks and potentially I can remove it. Unfortunately there is no easy was to change the code since it is in the framework itself. I may try to inherit the X509Certificate2 object and rewrite PublicKey and PrivateKey, but I don't really like that idea.
I am using stripe connect(destination payment) with the help of stripe.net library from Jaymedavis.
The problem that I am facing is that I am not able to retrieve the destination payment ID to update the metadata in the connected account. The following line returns a null preventing me from updating meta data on the connected account. But the strange thing is that when I log in to the dashboard the destination payment ID exists. I am not sure why I am not able to retreive it in code.
Is the charge creation asynchronous?. I am not sure. Stripe's connect documentation does not help either. The following line returns a null. My code is down below. Seeking help.
String deschargeID = result.Transfer.DestinationPayment;
Here is the code that I am using
var service = new StripeChargeService(ZambreroSecretKey);
var result = (Stripe.StripeCharge) null;
try {
result = service.Create(newCharge);
if (result.Paid) {
//get the chargeID on the newgen account and update the metadata.
//Returns null even though it exists in the dashboard
String deschargeID = result.Transfer.DestinationPayment;
var chargeService = new StripeChargeService(newgenSecretKey);
StripeCharge charge = chargeService.Get(deschargeID);
charge.Metadata = myDict;
Response.Redirect("PgeCustSuccess.aspx?OrderID=" + OrderID);
}
} catch (StripeException stripeException) {
Debug.WriteLine(stripeException.Message);
stripe.Text = stripeException.Message;
}
The charge object's transfer attribute is not expanded by default, meaning it's just a string with the ID of the transfer object ("tr_..."), not a full transfer object.
According to Stripe.net's documentation, you can expand the transfer attribute by adding this line:
service.ExpandTransfer = True
before sending the charge creation request.
My project requires me to programmatically access TFS servers we don't administer and to get real time information about the fields in the WorkItemTypes. I can get the field names and most of the information I need by looking at the FieldDefinition in the WorkItemType's FieldDefinitions collection.
public WitType(WorkItemType type)
{
this.Fields = new List<string>();
foreach (FieldDefinition f in type.FieldDefinitions)
{
Fields.Add(f.Name);
}
}
One thing missing is the IsRequired property. I need to be able to tell if a field is required.
I have tried running a work item story query
WorkItemCollection workItemCollection = workItemStore.Query
foreach (WorkItem workItem in workItemCollection)
foreach (Field field in workItem.Fields)
{
textBox1.Text += field.Name + " is required? " + field.IsRequired.ToString();
}
and then checking the IsRequired property of the Field item in the WorkItem's Fields collection.
Only problem is that for a given work item type one work item says Title is required, then the next work item will have the IsRequired property = false.
Is there a way to determine if a WorkItem field is required without resorting to the WIT xml file? If not, is there a way to programmatically access the WIT xml file?
I needed to perform a similar task, and the following was the only way I could figure out how to accomplish it.
As mentioned by others, WorkItem validation is defined in the WorkItemType's template. Fields can have different validation requirements based on the WorkItem's current state and even the current user's permissions.
Therefore, you need to create/retrieve a WorkItem instance using the user's credentials. If your application is impersonating the current user (i.e. in an ASP.NET application using Windows Authentication and impersonation), then you can simply use Option 1, where you use the TFS API to get the WorkItem, without impersonating.
If you're application is not impersonating the user, when you can use Option 2, where you use the TFS impersonation feature, to make calls on-behave of a user. This requires granting the "Make Requests on behave of others" permission in TFS to the application's identity (i.e. in ASP.NET the application pool's identity). See the following link for more information:
http://blogs.microsoft.co.il/blogs/shair/archive/2010/08/23/tfs-api-part-29-tfs-impersonation.aspx
The following code is an example on how to do Option 1 and Option 2.
// Set the following variables accordingly
string workItemTypeName = "Bug";
string teamProjectName = "My Project";
string usernameToImpersonate = "joesmith";
string tfsTeamProjectCollectionUrl = "http://mydomain.com:8080/tfs/ProjectCollectionName";
// OPTION 1: no impersonation.
// Get an instance to TFS using the current thread's identity.
// NOTE: The current thread's identity needs to have the "" permision or else you will receive
// a runtime SOAP exception: "Access Denied: [username] needs the following permission(s) to perform this action: Make requests on behalf of others"
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection( new Uri( tfsTeamProjectCollectionUrl ) );
IIdentityManagementService identityManagementService = tfs.GetService<IIdentityManagementService>();
// OPTION 2: impersonation. Remove the following two lines of code if you don't need to impersonate.
// Get an instance to TFS impersonating the specified user.
// NOTE: This is not needed if the current thread's identity is that of the user
// needed to impersonate. Simple use the ablve TfsTeamProjectCollection instance
TeamFoundationIdentity identity = identityManagementService.ReadIdentity( IdentitySearchFactor.AccountName, usernameToImpersonate, MembershipQuery.None, ReadIdentityOptions.None );
tfs = new TfsTeamProjectCollection( tfs.Uri, identity.Descriptor );
WorkItem workItem = null;
WorkItemStore store = tfs.GetService<WorkItemStore>();
// Determine if we are creating a new WorkItem or loading an existing WorkItem.
if( workItemId.HasValue ) {
workItem = store.GetWorkItem( workItemId.Value );
}
else {
Project project = store.Projects[ teamProjectName ];
WorkItemType workItemType = project.WorkItemTypes[ workItemTypeName ];
workItem = new WorkItem( workItemType );
}
if( workItem != null ) {
foreach( Field field in workItem.Fields ) {
if( field.IsRequired ) {
// TODO
}
}
}